Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 12
    @Darin - but there is an order in the serialization. "{ id: 1, name: 'John' }" and "{ name: 'John', id: 1 }" are different as strings, which is what I care about here. Of course, the objects are equivalent when deserialized. Commented Jul 25, 2010 at 21:09
  • 1
    @Darin - no, not in this case. I'm serializing something and then passing it along as a string to a service that only deals in strings (not JSON aware), and it'd be convenient for a variety of reasons for one field to appear first in the string. Commented Jul 25, 2010 at 21:27
  • 1
    its good for testing also, being able to just look at the strings rather than having to deserialize. Commented Dec 26, 2012 at 2:21
  • 9
    A stable serialization order is handy for cache validation too. It's trivial to take a checksum of a string - not true of a full object graph. Commented Mar 6, 2015 at 19:25
  • 1
    Serialization order is also handy when doing unit tests so that you can easily say that expected vs actual response strings are equal even when the order of the json properties are different. Commented Apr 11, 2017 at 15:55