Reputation:
I am new to JSON (not C#) and am trying to deserialize the following:
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.
Can someone please advise what I am missing.
Thanks in advance. NOTE: I am using JSON.NET api
Upvotes: 0
Views: 122
Reputation: 1059
Coord is not a decimal list. It would be in brackets. Create an coord class with lat and lon.
Upvotes: 0