I have a JObject
(I'm using Json.Net) that I constructed with LINQ to JSON (also provided by the same library). When I call the ToString()
method on the JObject
, it outputs the results as formatted JSON.
How do I set the formatting to "none" for this?
This question is related to
json
serialization
json.net
you can use JsonConvert.SerializeObject()
JsonConvert.SerializeObject(myObject) // myObject is returned by JObject.Parse() method
You can also do the following;
string json = myJObject.ToString(Newtonsoft.Json.Formatting.None);
Source: Stackoverflow.com