I have a requirement to generate JSON that is always sorted in the same way.
Using JSON.NET I've implemented this by first serializing the object to a json string then deserealizing into a sorted dictionary, using StringComparer.Ordinal as the sort order (the order I require) and then serializing that to a json string. This works well but only for the set of properties that belong to the top level object.
Once there are sub-objects, sub-dictionaries, sub-lists, etc, this won't work.
I've looked in the documentation but I can't find anything to do with sorting, so my question is:
Is there a way to set JSON.NET to use a particular sort order when serializing to a string?