Possible Duplicate:
Removing all whitespace from a string efficiently
Minify indented JSON string in .NET
I have a string like this:
{"languages" : [{"fluency": 4, "id": 15}], "address" : {"city_id" : 8341, "city_name" : "My city"}, "about" : null, "birthday" : "1988-03-18", "email" : "email@a.com", "id" : 3, "income" : 4}
I would like to have a compact/minified string like this:
{"languages":[{"fluency":4,"id":15}],"address":{"city_id":8341,"city_name":"My city"},"about":null,"birthday":"1988-03-18","email":"email@a.com","id":3,"income":4}
NOTE:
- I'm using the built in
System.Json
to perform serialization in my app. I retrieve the string representation of aJsonValue
object using theToString ()
method, but looks like I have no control over the format of the output string. - I'd like to use a helper method to 'minify' the JSON string. I don't want to include another third party Json library in the project.
- I'm using complex JSON data structures (including nested objects/arrays)
- I'm using Mono, not .NET