Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

dart to json

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;
  }
}
Source by javiercbk.github.io #
 
PREVIOUS NEXT
Tagged: #dart #json
ADD COMMENT
Topic
Name
9+1 =