5

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

Vladimir
  • 103
  • 1
  • 1
  • 7

2 Answers2

21

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

string json = jObject.ToString(Formatting.None);
Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
0

JsonConvert.SerializeObject(myJson);

Json.Net SerializeObject

Arezoo
  • 1