11,570 questions
You can define classes that correspond to JSON structure, for example:
struct Location
{
public double X, Y;
}
struct Attributes
{
public int ResultID;
}
class Item
{
public string address;
public Location location;
public int score;
public Attributes attributes;
}
. . .
string example = @"[
{
'address': '2500 S Linden Rd, Flint, Michigan, 48532',
'location': {
'x': -83.77313303899996,
'y': 42.988088994000066
},
'score': 100,
'attributes': {
'ResultID': 84401,
'Loc_name': 'World',
'Status': 'M'
}
},
{
'address': '2501 S Linden Rd, Flint, Michigan, 48532',
'location': {
'x': -84.77313303899996,
'y': 43.988088994000066
},
'score': 101,
'attributes': {
'ResultID': 84401,
'Loc_name': 'World',
'Status': 'X'
}
}
]";
List<Item> items = JsonConvert.DeserializeObject<List<Item>>( example );
If you prefer dynamic data:
dynamic responseContent = JsonConvert.DeserializeObject( example );
foreach( dynamic i in responseContent )
{
string address = i.address;
double x = i.location.x;
double y = i.location.y;
int score = i.score;
int resultID = i.attributes.ResultID;
// . . . add to list . . .
}