I want to generate custom json from this Model:
class Book {
List<Route> routes;
double distance;
int rateId;
List<int> optionsIds;
String comment;
int regionId;
}
class Route {
double lat;
double lng;
int order;
String address;
}
var book = Book();
book.routes = [Route(lat: 12, lng: 12, order: 0,address: 'address1'), Route(lat: 12, lng: 12, order: 1,address: 'address2')];
book.distance = 10.3;
book.rateId = 0;
book.optionsIds = [1,2];
book.comment = 'book comment';
book.regionId = 1;
I need this json:
{
"routes[0][address]": "Aviasozlar, 24",
"routes[0][lat]": 12,
"routes[0][lng]": 12,
"routes[0][order]": 0,
"routes[1][address]": "Mustaqillik maydoni",
"routes[1][lat]": 12,
"routes[1][lng]": 12,
"routes[1][order]": 1,
"distance": 12,
"rate_id": 1,
"option_ids[]": 1,
"option_ids[]": 2,
"comment": "komment 1",
"region_id": 1,
}
Ignore this text: It looks like your post is mostly code; please add some more details.
Ignore this text: It looks like your post is mostly code; please add some more details.