Generate JSON object with NewtonSoft in a single line

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);

Leave a Comment