[英]C# - Deserialize JSON object array
I am new to JSON (not C#) and am trying to deserialize the following: 我是JSON(不是C#)的新手,正在尝试反序列化以下内容:
var content =
{"message":"","cod":"200","calctime":"","cnt":1,"list":[{"id":80678,"dt":1439083410,"name":"rvb.name","type":5,"coord":{"lat":55.4033,"lon":37.5617},"distance":57.285,"main":{"temp":288.15,"pressure":999.6,"humidity":76},"rang":1}]}
My Code: 我的代码:
}
public class Location
{
public string message { get; set; }
public string cod { get; set; }
public string calcutime { get; set; }
public int cnt { get; set; }
public List<decimal> coord { get; set; }
public int distance { get; set; }
}
Location loc = JsonConvert.DeserializeObject<Location>(content);
However, when I deserialize it it will not populate the lat and long attributes. 但是,当我反序列化它时,它不会填充lat和long属性。
Can someone please advise what I am missing. 有人可以告诉我我所缺少的吗?
Thanks in advance. 提前致谢。 NOTE: I am using JSON.NET api
注意:我正在使用JSON.NET API
Check your JSON serial/deserial(ization) classes with: 使用以下命令检查您的JSON序列/反序列化类:
http://json2csharp.com/ http://json2csharp.com/
=) =)
Coord is not a decimal list. 坐标不是十进制列表。 It would be in brackets.
它将放在方括号中。 Create an coord class with lat and lon.
用lat和lon创建一个coord类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.