I would like to convert a JSON string
"{ \"birthday\": \"1988-03-18\", \"address\": { \"state\": 24, \"city\": 8341, \"country\": 1 } }"
to
"{ \"address\": { \"city\": 8341, \"country\": 1, \"state\": 24 }, \"birthday\": \"1988-03-18\" }"
NOTE. I don't use the sorted version for communication (because the order of the keys doesn't really matter), I need a sorted version to run local tests (by comparing JSON strings).
EDIT: I4V pointed out a solution that uses Json.Net , I would prefer to use a solution, t you need to include any third-party library (in fact I use the built-in System.Json in my application)
I posted the gist with the solution provided by I4V + for testing here . Thanks to everyone.
Eduardo coelho
source share