You can use json2dart to convert your json to dart classes even complex and nested json datas will work perfectly.
Here is dart class version of your given json data:
class Autogenerated {
NewDataSet newDataSet;
Autogenerated({this.newDataSet});
Autogenerated.fromJson(Map<String, dynamic> json) {
newDataSet = json['NewDataSet'] != null
? new NewDataSet.fromJson(json['NewDataSet'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.newDataSet != null) {
data['NewDataSet'] = this.newDataSet.toJson();
}
return data;
}
}
class NewDataSet {
List<Route> route;
NewDataSet({this.route});
NewDataSet.fromJson(Map<String, dynamic> json) {
if (json['Route'] != null) {
route = new List<Route>();
json['Route'].forEach((v) {
route.add(new Route.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.route != null) {
data['Route'] = this.route.map((v) => v.toJson()).toList();
}
return data;
}
}
class Route {
String routeID;
String routeNum;
String description;
Route({this.routeID, this.routeNum, this.description});
Route.fromJson(Map<String, dynamic> json) {
routeID = json['RouteID'];
routeNum = json['RouteNum'];
description = json['Description'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['RouteID'] = this.routeID;
data['RouteNum'] = this.routeNum;
data['Description'] = this.description;
return data;
}
}