I'm trying to deserialize the following json string in C# but it's not working correctly.
The following code returns a count of 0. I'm not sure what I'm doing wrong.
JavaScriptSerializer ser = new JavaScriptSerializer();
Addresses addresses = ser.Deserialize<Addresses>(json);
My JSON is:
{
"addresses":[
{
"first_name":"Sarah",
"last_name":"Halawani",
"line1":"1653 OCEAN PKWY",
"company":"",
"city":"BROOKLYN",
"state":"NY",
"subscriber_id":null,
"country_name":"United States",
"country_abbreviation":"USA",
"latitude":"40.6085",
"longitude":"-73.9675",
"verified":true
},
{
"first_name":"Jean",
"last_name":"Mizrahi",
"line1":"1733 OCEAN PKWY",
"company":"",
"city":"BROOKLYN",
"state":"NY",
"subscriber_id":null,
"country_name":"United States",
"country_abbreviation":"USA",
"latitude":"40.6065",
"longitude":"-73.9671",
"verified":true
}
]
}
And my classes are:
public class Addresses
{
public List<Address> address { get; set; }
public Addresses() { address = new List<Address>(); }
}
public class Address
{
public string first_name { get; set; }
public string last_name { get; set; }
public string line1 { get; set; }
public string company { get; set; }
}