Generate JSON object with NewtonSoft in a single line

后端 未结 5 2055
自闭症患者
自闭症患者 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:52

    If someone here who doesn't want to use any external library in MVC, they can use the inbuilt System.Web.Script.Serialization.JavaScriptSerializer

    One liner for that will be:

    var JsonString = new JavaScriptSerializer().Serialize(new { typ = "photos" });
    

提交回复
热议问题