我有个例外:
HResult=0x80131500
从API反序列化响应数据时。
(帖子结尾处有完整的例外)
代码
return JsonConvert.DeserializeObject(webResponseEntity.ResponseData, typeof(CarLookupResponse)) as CarLookupResponse;
模型
public class CarLookupResponse : ICarLookupResponse
{
public ICarLookupResult Result { get; set; }
public ICarLookupOutputObject OutputObject { get; set; }
public CarLookupResponse()
{
Result = new CarLookupResult();
OutputObject = new CarLookupOutputObject();
}
}
输出对象接口
public interface ICarLookupOutputObject
{
int CarId { get; set; }
string CartestId { get; set; }
int[] ModelYears { get; set; }
string FirstName { get; set; }
string LastName { get; set; }
string Email { get; set; }
string SSN { get; set; }
string Address { get; set; }
}
JSON格式
{
"result": {
"id": 1,
"value": "lookup successful.",
"error": null
},
"outputObject": {
"CarId": 2025,
"CartestId": "testing-02",
"ModelYears": [
2017,
2018
],
"firstName": "Troy",
"lastName": "Aaster",
"email": "testuser@gmail.com",
"address": {
"apartment": "",
"state": "CA",
"city": "BRISBANE",
"zipCode": "94005",
"streetAddress": "785, SPITZ BLVD"
},
"ssn": "511-04-6666"
}
}
JSON格式
是有效的,我已经检查过了。
Newtonsoft.Json.JsonReaderException
HResult=0x80131500
源=Newtonsoft.Json
堆栈跟踪:
在Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType ReadType)
在Newtonsoft.Json.JsonTextReader.ReadAsString()
在Newtonsoft.Json.JsonReader.ReadForType(Json contract契约,布尔hascoverter)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject,JsonReader reader,JsonObjectContract contract,JsonProperty member,String id)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader读取器,类型objectType,JsonContract协定,JsonProperty成员,JsonContainerContract containerContract,JsonProperty containerMember,对象existingValue)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue上(JsonProperty属性、JsonConverter属性Converter、JsonContainerContract containerContract、JsonProperty containerProperty、JsonReader读取器、对象目标)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject,JsonReader reader,JsonObjectContract contract,JsonProperty member,String id)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader读取器,类型objectType,JsonContract协定,JsonProperty成员,JsonContainerContract containerContract,JsonProperty containerMember,对象existingValue)
在Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Json reader reader,Type objectType,Boolean checkAdditionalContent)
在Newtonsoft.Json.JsonSerializer.DeserializeInternal(Json reader reader,键入objectType)
在Newtonsoft.Json.JsonConvert.DeserializeObject(字符串值、类型类型、JsonSerializerSettings设置)