I have an issue with the JObject.ToString()
method. I am trying to save the object data in a JSON file. The problem here is, I kind of want to use a mix between Formatting.None
and Formatting.Indented
. I want to print every item in a new row, but if there is a list, I want the list values in one row only and not for each item a new line.
The format should look like this:
{
"Vector": [1,2,3,4,5]
"Name": null
}
Currently, if I use Formatting.None
I get this:
{"Vector":[1,2,3,4,5],"Name":null}
And if I use Formatting.Indented
, I get this:
{
"Vector": [
1,
2,
3,
4,
5
],
"Name": null
}
Is there a way to use Formatting.None
only for lists and Formatting.Indented
for every other data type?