<分区>
我正在使用 Newton 的 Json.Net 将 Json 反序列化为 .NET 对象。我想了解是否可以从一般对象转换为特定对象。
即:
object myObject JsonConvert.DeserializeObject<object>(myJsonValue);
myOrder = (Order)myObject;
代码更多的是描述我的问题。我知道可以这样做:
object myObject JsonConvert.DeserializeObject<order>(myJsonValue);
但由于这是一个辅助函数,所以它不能是“顺序”,而是更一般的东西。
谢谢。
编辑:
获取错误:
Getting Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Order'