Removing unnecessary spaces from JSON output

I am sterilizing a JSON.Net object and contains many arrays. Here is the result that I am currently getting:

"children": [ { "children": [ { }, { } } 

However, just for the convenience of reading and comparing, I would like to remove line breaks between each curly brace and bracket and between the comma and the next bracket, so it looks like this:

 "children": [ { "children": [ { }, { } } 

I already sterilize my JSON with the Formatting.Indented argument, so I would like to know if there is another parameter that I can change so that JSON.Net sterilizes without additional linear brakes, but keeps formatting indented.

+4
source share
2 answers

There is no way in Json.NET to tell you such an indent. You will have to either do it yourself outside of Json.NET, or change the source code.

+3
source

Can you split by '{' and then rejoin the array with spaces?

0
source

Source: https://habr.com/ru/post/1443956/


All Articles