json序列化对象为 object对象

当序列化对象为一个未知的类型时,可以采用下列方式序列化为object对象,然后再强转成指定类型的对象。

 

Of course, if you don’t specify a type when you call DeserializeObject, or you use object or dynamic, then Json.Net has no choice but to deserialize into a JObject. (You can see for yourself that your dynamic variable actually holds a JObject by checking jResults.GetType().FullName.) So in that case, there’s not much difference between JsonConvert.DeserializeObject and JToken.Parse; either will give you the same result.

Leave a Comment

电子邮件地址不会被公开。 必填项已用*标注

计算器