C# 使用JSON文本读取器反序列化时出现JSON错误消息
我在尝试从流读取JSON时遇到此错误: Newtonsoft.Json.JsonSerializationException:'读取数据表时出现意外的Json标记。应该是StartArray,得到字符串。路径'Data.GUID',第1行,位置110' 行C# 使用JSON文本读取器反序列化时出现JSON错误消息,c#,json,json.net,C#,Json,Json.net,我在尝试从流读取JSON时遇到此错误: Newtonsoft.Json.JsonSerializationException:'读取数据表时出现意外的Json标记。应该是StartArray,得到字符串。路径'Data.GUID',第1行,位置110' 行syncResult=serializer.Deserialize(json) 问题是你错过了一个外部类。您正试图反序列化为一个SyncResult,但该对象实际上是JSON中较低一级的对象 尝试定义以下包装器类: public class R
syncResult=serializer.Deserialize(json)
问题是你错过了一个外部类。您正试图反序列化为一个
SyncResult
,但该对象实际上是JSON中较低一级的对象
尝试定义以下包装器类:
public class ResultWrapper
{
public string ContentEncoding { get; set; }
public string ContentType { get; set; }
public SyncResult Data { get; set; }
public long JsonRequestBehavior { get; set; }
public int? MaxJsonLength { get; set; }
public int? RecursionLimit { get; set; }
}
然后反序列化到包装器中,并从中获取SyncResult
:
syncResult = serializer.Deserialize<ResultWrapper>(json).Data;
问题是你错过了一个外部类。您正试图反序列化为一个
SyncResult
,但该对象实际上是JSON中较低一级的对象
尝试定义以下包装器类:
public class ResultWrapper
{
public string ContentEncoding { get; set; }
public string ContentType { get; set; }
public SyncResult Data { get; set; }
public long JsonRequestBehavior { get; set; }
public int? MaxJsonLength { get; set; }
public int? RecursionLimit { get; set; }
}
然后反序列化到包装器中,并从中获取SyncResult
:
syncResult = serializer.Deserialize<ResultWrapper>(json).Data;
syncResult = serializer.Deserialize<ResultWrapper>(json).Data;
public class ResultWrapper
{
public SyncResult Data { get; set; }
}