我正在尝试反序列化来自withings API的响应,但它仍然失败。
"{\"status\":0,\"body\":{\"updatetime\":1494443028,\"measuregrps\":[{\"grpid\":793454575,\"attrib\":0,\"date\":1494373242,\"category\":1,\"measures\":[{\"value\":88,\"type\":9,\"unit\":0},{\"value\":129,\"type\":10,\"unit\":0},{\"value\":49,\"type\":11,\"unit\":0}]}],\"timezone\":\"America\\/Chicago\"}}"
var response = client.Execute<WithingsWeighInResponse>(request);
public class WithingsWeighInResponse
{
public WithingsBody body { get; set; }
public int status { get; set; }
}
public class WithingsBody
{
public IList<Measuregrp> measuregrps { get; set; }
public string timezone { get; set; }
public int updatetime { get; set; }
}
public class Measuregrp
{
public int attrib { get; set; }
public int category { get; set; }
public int date { get; set; }
public int grpid { get; set; }
public IList<WithingsMeasure> measures { get; set; }
}
public class WithingsMeasure
{
public string ReadingType { get; }
public double ReadingValue { get; }
public int type { get; set; }
public int unit { get; set; }
public int value { get; set; }
}
答案 0 :(得分:0)
这可能是给定数据集的Int溢出问题。因为,json格式正确,我建议将以下属性的数据类型从int更改为string,然后测试相同: -
答案 1 :(得分:0)
我不能评论所以我必须留下答案......
不要说明显而易见但确保在实际使用数据时不要包含封装引号,Json对象始终以{和end with}开头, 这可能会导致第1行,第1位,错误信息。