I have JSON response with the following object structure:
{
"cities": {
"5": {
"id": "5",
"name": "New York"
},
"6": {
"id": "6",
"name": "Los Angeles"
}
},
"total": 2,
"page": 1,
"total_pages": 1
}
As you can see, "cities" is clearly an associative type array that is listing all the cities being referenced. I'm trying to create a Dart object that can hold these cities values from a JSON object. The city object is pretty straightforward:
class City {
int id;
String name;
City(this.id, this.name);
City.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
}
however, I'm not sure how to create the CityResults object. I usually create a List object from json arrays but I'm not sure how this would work?