我有 2 个相当复杂的对象,一个解析成功,另一个抛出异常。对象之间的唯一区别是 2 双类型属性。我将它反序列化为
var item = JsonConvert.DeserializeObject<MyItem>(result.ToString());
WhereMyItem
包含两行,所以在第一种情况下它们应该是空的(项目不包含它们),在第二种情况下它们应该被设置(因为它们存在于 json 和反序列化对象中)。
痕迹:
at Newtonsoft.Json.Utilities.ConvertUtils.IntParseFast(Char[] value, Int32 start, Int32 length)
at Newtonsoft.Json.JsonTextReader.ParseNumber()
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonReader.ReadAsInt32Internal()
at Newtonsoft.Json.JsonTextReader.ReadAsInt32()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
有什么建议么?