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 like so:
string jsonSTRINGResult = JsonConvert.SerializeObject(someObj);
One could then deserialize that back to a JObject
as follows:
JObject jObj = JsonConvert.DeserializeObject<JObject>(jsonSTRINGResult);
这似乎是可行的,但这种方式似乎对性能有双重影响(序列化,然后反序列化).SerializeObject
内部是否使用了可以通过某种方式访问的JObject
?或者有没有办法直接序列化到JObject
?