There are many ways to ask that question; some are more formal than others, some are grammatically wanting, and some are downright confusing. StackOverflow has plenty of ungrammatical English, so don't assume it is a paragon for English usage.
How do I serialize an object ...?
This is another way of asking "How can I ...?" except it literally asks the reader to guess how the writer does a serialization. It is informal and well understood, however.
How do you serialize an object ...?
This is also an informal phrasing, but its literal inquiry is not a departure: the OP may want to know how you do a thing, and that is what is being asked.
How to serialize an object ...?
The most charitable view of this phrasing is that it is a rhetorical phrasing using ellipsis. It will likely be understood, but may sound awkward unless finished deftly or followed with capable writing.
Other variants include:
How can I ...?
How does one ...?
What is the best way to ...?
Which approach is better: A or B?
And so on. There is no single correct way to ask a question.