Trim json string in JSON.NET

I am using the JObject.ToString() method to convert a JSON object to a string. But how can I trim the output to remove spaces between tokens?

+2
source share
2 answers

No need to resort to using Regex. Just use the Formatting.None parameter:

 string json = jObject.ToString(Formatting.None); 
+9
source

JsonConvert.SerializeObject (myJson);

Json.Net SerializeObject

0
source

All Articles