Serialize an object directly to a JObject instead of to a string in json.net

后端 未结 3 1708
天涯浪人
天涯浪人 2021-02-03 19:11

How might one serialize an object directly to a JObject instance in JSON.Net? What is typically done is to convert the object directly to a json string lik

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-03 19:38

    You can use FromObject static method of JObject

    JObject jObj = JObject.FromObject(someObj)
    

    http://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JObject_FromObject.htm

提交回复
热议问题