I'm using the JSON library NewtonSoft to generate a JSON string:
JObject out = JObject.FromObject(new { typ = "photos" }); return out.ToString();
Output:
{ "typ": "photos" }
My question: Is it possible to get the output in a single line like:
{"typ": "photos"}
You can use the overload of JObject.ToString()
which takes Formatting
as parameter:
JObject obj = JObject.FromObject(new { typ = "photos" }); return obj.ToString(Formatting.None);
var json = JsonConvert.SerializeObject(new { typ = "photos" }, Formatting.None);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With