我尝试反序列化来自withings的响应,但总是失败。
响应
"{\"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\"}}"Restsharp请求
var response = client.Execute<WithingsWeighInResponse>(request);WithingWeighInResponse
public class WithingsWeighInResponse
{
public WithingsBody body { get; set; }
public int status { get; set; }
}WithingsBody
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; }
}WithingsMeasure
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; }
}发布于 2017-05-11 03:31:19
这可能是给定数据集的Int溢出问题。由于json格式正确,我建议将以下属性的数据类型从int更改为string,然后进行相同的测试:
发布于 2017-05-11 03:46:41
我不能评论,所以我必须留下一个答案...
在实际使用数据时,Json对象总是以{开头,以}结尾,这可能会导致行1,位置1,错误消息。
https://stackoverflow.com/questions/43900932
复制相似问题