Generate JSON object with NewtonSoft in a single line

后端 未结 5 2043
自闭症患者
自闭症患者 2020-12-04 20:49

I\'m using the JSON library NewtonSoft to generate a JSON string:

JObject out = JObject.FromObject(new
            {
                typ = \"photos\"
                


        
5条回答
  •  时光取名叫无心
    2020-12-04 21:41

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

提交回复
热议问题