import 'dart:convert';
main() {
String nestedObjText =
'{"title": "Dart Tutorial", "description": "Way to parse Json", "author": {"name": "bezkoder", "age": 30}}';
Tutorial tutorial = Tutorial.fromJson(jsonDecode(nestedObjText));
print(tutorial);
class BannersModel {
bool? status;
List<Banners>? banners;
BannersModel({this.status, this.banners});
BannersModel.fromJson(Map<String, dynamic> json) {
status = json['status'];
if (json['banners'] != null) {
banners = <Banners>[];
json['banners'].forEach((v) {
banners!.add(new Banners.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
if (this.banners != null) {
data['banners'] = this.banners!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Banners {
String? id;
String? image;
Banners({this.id, this.image});
Banners.fromJson(Map<String, dynamic> json) {
id = json['id'];
image = json['image'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['image'] = this.image;
return data;
}
}
class SendSyncedRequestModel {
String? idUser;
List<Alarms>? alarms;
SendSyncedRequestModel({this.idUser, this.alarms});
SendSyncedRequestModel.fromJson(Map<String, dynamic> json) {
idUser = json['idUser'];
if (json['alarms'] != null) {
alarms = <Alarms>[];
json['alarms'].forEach((v) {
alarms!.add(new Alarms.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['idUser'] = this.idUser;
if (this.alarms != null) {
data['alarms'] = this.alarms!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Alarms {
String? publicAlarmId;
String? privateAlarmId;
String? name;
String? mobileAESKey;
String? newKeyMessage;
String? status;
Alarms(
{this.publicAlarmId,
this.privateAlarmId,
this.name,
this.mobileAESKey,
this.newKeyMessage,
this.status});
Alarms.fromJson(Map<String, dynamic> json) {
publicAlarmId = json['publicAlarmId'];
privateAlarmId = json['privateAlarmId'];
name = json['name'];
mobileAESKey = json['mobileAESKey'];
newKeyMessage = json['newKeyMessage'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['publicAlarmId'] = this.publicAlarmId;
data['privateAlarmId'] = this.privateAlarmId;
data['name'] = this.name;
data['mobileAESKey'] = this.mobileAESKey;
data['newKeyMessage'] = this.newKeyMessage;
data['status'] = this.status;
return data;
}
}