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

var json = JsonConvert.SerializeObject(new { typ = "photos" }, Formatting.None);

Here's a one-liner to minify JSON that you only have a string for:

var myJson = "{\"type\"    :\"photos\"               }";
JObject.Parse(myJson).ToString(Newtonsoft.Json.Formatting.None)

Output:

{"type":"photos"}

I'm not sure if this is what you mean, but what I do is this::

string postData = "{\"typ\":\"photos\"}";

EDIT: After searching I found this on Json.Net:

string json = @"{
  CPU: 'Intel',
  Drives: [
    'DVD read/writer',
    '500 gigabyte hard drive'
  ]
}";

JObject o = JObject.Parse(json);

and maybe you could use the info on this website.

But I'm not sure, if the output will be on one line... Good luck!