Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert json to dart

class TrendingMoviesModel {
  String? name;
  String? backdropPath;
  List<int>? genreIds;
  String? originalLanguage;
  String? posterPath;
  List<String>? originCountry;
  String? overview;
  String? mediaType;

  TrendingMoviesModel(
      {this.name,
      this.backdropPath,
      this.genreIds,
      this.originalLanguage,
      this.posterPath,
      this.originCountry,
      this.overview,
      this.mediaType});

  TrendingMoviesModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    backdropPath = json['backdrop_path'];
    genreIds = json['genre_ids'].cast<int>();
    originalLanguage = json['original_language'];
    posterPath = json['poster_path'];
    originCountry = json['origin_country'].cast<String>();
    overview = json['overview'];
    mediaType = json['media_type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['backdrop_path'] = this.backdropPath;
    data['genre_ids'] = this.genreIds;
    data['original_language'] = this.originalLanguage;
    data['poster_path'] = this.posterPath;
    data['origin_country'] = this.originCountry;
    data['overview'] = this.overview;
    data['media_type'] = this.mediaType;
    return data;
  }
}
Comment

json to dart

class Autogenerated {
  int? id;
  int? age;
  String? name;

  Autogenerated({this.id, this.age, this.name});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    age = json['age'];
    name = json['name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['age'] = this.age;
    data['name'] = this.name;
    return data;
  }
}
Comment

json to dart

class plates_hub {
  List<Data>? data;
  Meta? meta;

  plates_hub({this.data, this.meta});

  plates_hub.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = <Data>[];
      json['data'].forEach((v) {
        data!.add(new Data.fromJson(v));
      });
    }
    meta = json['meta'] != null ? new Meta.fromJson(json['meta']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    if (this.meta != null) {
      data['meta'] = this.meta!.toJson();
    }
    return data;
  }
}

class Data {
  int? id;
  Attributes? attributes;

  Data({this.id, this.attributes});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    attributes = json['attributes'] != null
        ? new Attributes.fromJson(json['attributes'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    if (this.attributes != null) {
      data['attributes'] = this.attributes!.toJson();
    }
    return data;
  }
}

class Attributes {
  String? plateName;
  int? platePrice;
  String? createdAt;
  String? updatedAt;
  String? publishedAt;

  Attributes(
      {this.plateName,
      this.platePrice,
      this.createdAt,
      this.updatedAt,
      this.publishedAt});

  Attributes.fromJson(Map<String, dynamic> json) {
    plateName = json['plate_name'];
    platePrice = json['plate_price'];
    createdAt = json['createdAt'];
    updatedAt = json['updatedAt'];
    publishedAt = json['publishedAt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['plate_name'] = this.plateName;
    data['plate_price'] = this.platePrice;
    data['createdAt'] = this.createdAt;
    data['updatedAt'] = this.updatedAt;
    data['publishedAt'] = this.publishedAt;
    return data;
  }
}

class Meta {
  Pagination? pagination;

  Meta({this.pagination});

  Meta.fromJson(Map<String, dynamic> json) {
    pagination = json['pagination'] != null
        ? new Pagination.fromJson(json['pagination'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.pagination != null) {
      data['pagination'] = this.pagination!.toJson();
    }
    return data;
  }
}

class Pagination {
  int? page;
  int? pageSize;
  int? pageCount;
  int? total;

  Pagination({this.page, this.pageSize, this.pageCount, this.total});

  Pagination.fromJson(Map<String, dynamic> json) {
    page = json['page'];
    pageSize = json['pageSize'];
    pageCount = json['pageCount'];
    total = json['total'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['page'] = this.page;
    data['pageSize'] = this.pageSize;
    data['pageCount'] = this.pageCount;
    data['total'] = this.total;
    return data;
  }
}
Comment

json to dart

class CoursesModel {
  List<Data>? data;

  CoursesModel({this.data});

  CoursesModel.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = <Data>[];
      json['data'].forEach((v) {
        data!.add(new Data.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Data {
  int? id;
  String? status;
  String? createdOn;
  String? title;
  Thumbnail? thumbnail;
  String? summery;
  String? slug;
  Category? category;
  String? link;
  String? coupon;

  Data(
      {this.id,
      this.status,
      this.createdOn,
      this.title,
      this.thumbnail,
      this.summery,
      this.slug,
      this.category,
      this.link,
      this.coupon});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    status = json['status'];
    createdOn = json['created_on'];
    title = json['title'];
    thumbnail = json['thumbnail'] != null
        ? new Thumbnail.fromJson(json['thumbnail'])
        : null;
    summery = json['summery'];
    slug = json['slug'];
    category = json['category'] != null
        ? new Category.fromJson(json['category'])
        : null;
    link = json['link'];
    coupon = json['coupon'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['status'] = this.status;
    data['created_on'] = this.createdOn;
    data['title'] = this.title;
    if (this.thumbnail != null) {
      data['thumbnail'] = this.thumbnail!.toJson();
    }
    data['summery'] = this.summery;
    data['slug'] = this.slug;
    if (this.category != null) {
      data['category'] = this.category!.toJson();
    }
    data['link'] = this.link;
    data['coupon'] = this.coupon;
    return data;
  }
}

class Thumbnail {
  Data? data;

  Thumbnail({this.data});

  Thumbnail.fromJson(Map<String, dynamic> json) {
    data = json['data'] != null ? new Data.fromJson(json['data']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.toJson();
    }
    return data;
  }
}

class Data {
  String? fullUrl;
  String? url;
  String? assetUrl;
  List<Thumbnails>? thumbnails;
  Null? embed;

  Data({this.fullUrl, this.url, this.assetUrl, this.thumbnails, this.embed});

  Data.fromJson(Map<String, dynamic> json) {
    fullUrl = json['full_url'];
    url = json['url'];
    assetUrl = json['asset_url'];
    if (json['thumbnails'] != null) {
      thumbnails = <Thumbnails>[];
      json['thumbnails'].forEach((v) {
        thumbnails!.add(new Thumbnails.fromJson(v));
      });
    }
    embed = json['embed'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['full_url'] = this.fullUrl;
    data['url'] = this.url;
    data['asset_url'] = this.assetUrl;
    if (this.thumbnails != null) {
      data['thumbnails'] = this.thumbnails!.map((v) => v.toJson()).toList();
    }
    data['embed'] = this.embed;
    return data;
  }
}

class Thumbnails {
  String? key;
  String? url;
  String? relativeUrl;
  String? dimension;
  int? width;
  int? height;

  Thumbnails(
      {this.key,
      this.url,
      this.relativeUrl,
      this.dimension,
      this.width,
      this.height});

  Thumbnails.fromJson(Map<String, dynamic> json) {
    key = json['key'];
    url = json['url'];
    relativeUrl = json['relative_url'];
    dimension = json['dimension'];
    width = json['width'];
    height = json['height'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['key'] = this.key;
    data['url'] = this.url;
    data['relative_url'] = this.relativeUrl;
    data['dimension'] = this.dimension;
    data['width'] = this.width;
    data['height'] = this.height;
    return data;
  }
}

class Category {
  int? id;

  Category({this.id});

  Category.fromJson(Map<String, dynamic> json) {
    id = json['id'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    return data;
  }
}
Comment

json data to dart

class Autogenerated {
  Id iId;
  String name;
  String email;
  String password;
  String address;
  String type;
  List<Null> cart;
  V vV;

  Autogenerated(
      {this.iId,
      this.name,
      this.email,
      this.password,
      this.address,
      this.type,
      this.cart,
      this.vV});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    iId = json['_id'] != null ? new Id.fromJson(json['_id']) : null;
    name = json['name'];
    email = json['email'];
    password = json['password'];
    address = json['address'];
    type = json['type'];
    if (json['cart'] != null) {
      cart = new List<Null>();
      json['cart'].forEach((v) {
        cart.add(new Null.fromJson(v));
      });
    }
    vV = json['__v'] != null ? new V.fromJson(json['__v']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.iId != null) {
      data['_id'] = this.iId.toJson();
    }
    data['name'] = this.name;
    data['email'] = this.email;
    data['password'] = this.password;
    data['address'] = this.address;
    data['type'] = this.type;
    if (this.cart != null) {
      data['cart'] = this.cart.map((v) => v.toJson()).toList();
    }
    if (this.vV != null) {
      data['__v'] = this.vV.toJson();
    }
    return data;
  }
}

class Id {
  String oid;

  Id({this.oid});

  Id.fromJson(Map<String, dynamic> json) {
    oid = json['$oid'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['$oid'] = this.oid;
    return data;
  }
}

class V {
  String numberInt;

  V({this.numberInt});

  V.fromJson(Map<String, dynamic> json) {
    numberInt = json['$numberInt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['$numberInt'] = this.numberInt;
    return data;
  }
}
Comment

json to dart

class Autogenerated {
  String foodOrderOption;
  String foodOrder;

  Autogenerated({this.foodOrderOption, this.foodOrder});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    foodOrderOption = json['foodOrderOption'];
    foodOrder = json['foodOrder'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['foodOrderOption'] = this.foodOrderOption;
    data['foodOrder'] = this.foodOrder;
    return data;
  }
}
Comment

convert json to dart

class TrendingMoviesModel {
  String? name;
  String? backdropPath;
  List<int>? genreIds;
  String? originalLanguage;
  String? posterPath;
  List<String>? originCountry;
  String? overview;
  String? mediaType;

  TrendingMoviesModel(
      {this.name,
      this.backdropPath,
      this.genreIds,
      this.originalLanguage,
      this.posterPath,
      this.originCountry,
      this.overview,
      this.mediaType});

  TrendingMoviesModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    backdropPath = json['backdrop_path'];
    genreIds = json['genre_ids'].cast<int>();
    originalLanguage = json['original_language'];
    posterPath = json['poster_path'];
    originCountry = json['origin_country'].cast<String>();
    overview = json['overview'];
    mediaType = json['media_type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['backdrop_path'] = this.backdropPath;
    data['genre_ids'] = this.genreIds;
    data['original_language'] = this.originalLanguage;
    data['poster_path'] = this.posterPath;
    data['origin_country'] = this.originCountry;
    data['overview'] = this.overview;
    data['media_type'] = this.mediaType;
    return data;
  }
}
Comment

json to dart

class Autogenerated {
  String? status;

  Autogenerated({this.status});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['status'] = this.status;
    return data;
  }
}
Comment

dart to json

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;
  }
}
Comment

json to dart

class Faclity {
  String? responseCode;
  String? responseMessage;
  List<Facilities>? facilities;

  Faclity({this.responseCode, this.responseMessage, this.facilities});

  Faclity.fromJson(Map<String, dynamic> json) {
    responseCode = json['ResponseCode'];
    responseMessage = json['ResponseMessage'];
    if (json['facilities'] != null) {
      facilities = <Facilities>[];
      json['facilities'].forEach((v) {
        facilities!.add(new Facilities.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ResponseCode'] = this.responseCode;
    data['ResponseMessage'] = this.responseMessage;
    if (this.facilities != null) {
      data['facilities'] = this.facilities!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Facilities {
  String? faclityCode;
  String? faclityDescription;

  Facilities({this.faclityCode, this.faclityDescription});

  Facilities.fromJson(Map<String, dynamic> json) {
    faclityCode = json['FaclityCode'];
    faclityDescription = json['FaclityDescription'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['FaclityCode'] = this.faclityCode;
    data['FaclityDescription'] = this.faclityDescription;
    return data;
  }
}
Comment

json to dart

class Seats {
  int? code;
  bool? status;
  String? message;
  List<Data>? data;

  Seats({this.code, this.status, this.message, this.data});

  Seats.fromJson(Map<String, dynamic> json) {
    code = json['code'];
    status = json['status'];
    message = json['message'];
    if (json['data'] != null) {
      data = <Data>[];
      json['data'].forEach((v) {
        data!.add(new Data.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    data['status'] = this.status;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Data {
  int? id;
  String? name;
  int? salonId;
  int? staffId;
  String? createdAt;
  String? updatedAt;

  Data(
      {this.id,
      this.name,
      this.salonId,
      this.staffId,
      this.createdAt,
      this.updatedAt});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    salonId = json['salon_id'];
    staffId = json['staff_id'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['salon_id'] = this.salonId;
    data['staff_id'] = this.staffId;
    data['created_at'] = this.createdAt;
    data['updated_at'] = this.updatedAt;
    return data;
  }
}
Comment

json to dart

class DataDTO {
  String? _name;
  String? _gender;
  int? _age;
  Address? _address;
  List<PhoneNumber>? _phoneNumber;

  DataDTO(
      {String? name,
      String? gender,
      int? age,
      Address? address,
      List<PhoneNumber>? phoneNumber}) {
    if (name != null) {
      this._name = name;
    }
    if (gender != null) {
      this._gender = gender;
    }
    if (age != null) {
      this._age = age;
    }
    if (address != null) {
      this._address = address;
    }
    if (phoneNumber != null) {
      this._phoneNumber = phoneNumber;
    }
  }

  String? get name => _name;
  set name(String? name) => _name = name;
  String? get gender => _gender;
  set gender(String? gender) => _gender = gender;
  int? get age => _age;
  set age(int? age) => _age = age;
  Address? get address => _address;
  set address(Address? address) => _address = address;
  List<PhoneNumber>? get phoneNumber => _phoneNumber;
  set phoneNumber(List<PhoneNumber>? phoneNumber) => _phoneNumber = phoneNumber;

  DataDTO.fromJson(Map<String, dynamic> json) {
    _name = json['name'];
    _gender = json['gender'];
    _age = json['age'];
    _address =
        json['address'] != null ? new Address.fromJson(json['address']) : null;
    if (json['phoneNumber'] != null) {
      _phoneNumber = <PhoneNumber>[];
      json['phoneNumber'].forEach((v) {
        _phoneNumber!.add(new PhoneNumber.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this._name;
    data['gender'] = this._gender;
    data['age'] = this._age;
    if (this._address != null) {
      data['address'] = this._address!.toJson();
    }
    if (this._phoneNumber != null) {
      data['phoneNumber'] = this._phoneNumber!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Address {
  String? _street;
  String? _city;
  String? _state;
  String? _postalCode;

  Address({String? street, String? city, String? state, String? postalCode}) {
    if (street != null) {
      this._street = street;
    }
    if (city != null) {
      this._city = city;
    }
    if (state != null) {
      this._state = state;
    }
    if (postalCode != null) {
      this._postalCode = postalCode;
    }
  }

  String? get street => _street;
  set street(String? street) => _street = street;
  String? get city => _city;
  set city(String? city) => _city = city;
  String? get state => _state;
  set state(String? state) => _state = state;
  String? get postalCode => _postalCode;
  set postalCode(String? postalCode) => _postalCode = postalCode;

  Address.fromJson(Map<String, dynamic> json) {
    _street = json['street'];
    _city = json['city'];
    _state = json['state'];
    _postalCode = json['postalCode'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['street'] = this._street;
    data['city'] = this._city;
    data['state'] = this._state;
    data['postalCode'] = this._postalCode;
    return data;
  }
}

class PhoneNumber {
  String? _type;
  String? _number;

  PhoneNumber({String? type, String? number}) {
    if (type != null) {
      this._type = type;
    }
    if (number != null) {
      this._number = number;
    }
  }

  String? get type => _type;
  set type(String? type) => _type = type;
  String? get number => _number;
  set number(String? number) => _number = number;

  PhoneNumber.fromJson(Map<String, dynamic> json) {
    _type = json['type'];
    _number = json['number'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['type'] = this._type;
    data['number'] = this._number;
    return data;
  }
}
Comment

json to dart

class Autogenerated {
  String? message;
  String? status;

  Autogenerated({this.message, this.status});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    message = json['message'];
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['message'] = this.message;
    data['status'] = this.status;
    return data;
  }
}
Comment

json to dart

class Autogenerated {
  bool? status;
  Null? message;
  Data? data;

  Autogenerated({this.status, this.message, this.data});

  Autogenerated.fromJson(Map<String, dynamic> json) {
    status = json['status'];
    message = json['message'];
    data = json['data'] != null ? new Data.fromJson(json['data']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['status'] = this.status;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data!.toJson();
    }
    return data;
  }
}

class Data {
  List<Banners>? banners;
  List<Products>? products;
  String? ad;

  Data({this.banners, this.products, this.ad});

  Data.fromJson(Map<String, dynamic> json) {
    if (json['banners'] != null) {
      banners = <Banners>[];
      json['banners'].forEach((v) {
        banners!.add(new Banners.fromJson(v));
      });
    }
    if (json['products'] != null) {
      products = <Products>[];
      json['products'].forEach((v) {
        products!.add(new Products.fromJson(v));
      });
    }
    ad = json['ad'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.banners != null) {
      data['banners'] = this.banners!.map((v) => v.toJson()).toList();
    }
    if (this.products != null) {
      data['products'] = this.products!.map((v) => v.toJson()).toList();
    }
    data['ad'] = this.ad;
    return data;
  }
}

class Banners {
  int? id;
  String? image;
  Null? category;
  Null? product;

  Banners({this.id, this.image, this.category, this.product});

  Banners.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    image = json['image'];
    category = json['category'];
    product = json['product'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['image'] = this.image;
    data['category'] = this.category;
    data['product'] = this.product;
    return data;
  }
}

class Products {
  int? id;
  double? price;
  double? oldPrice;
  int? discount;
  String? image;
  String? name;
  String? description;
  List<String>? images;
  bool? inFavorites;
  bool? inCart;

  Products(
      {this.id,
      this.price,
      this.oldPrice,
      this.discount,
      this.image,
      this.name,
      this.description,
      this.images,
      this.inFavorites,
      this.inCart});

  Products.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    price = json['price'];
    oldPrice = json['old_price'];
    discount = json['discount'];
    image = json['image'];
    name = json['name'];
    description = json['description'];
    images = json['images'].cast<String>();
    inFavorites = json['in_favorites'];
    inCart = json['in_cart'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['price'] = this.price;
    data['old_price'] = this.oldPrice;
    data['discount'] = this.discount;
    data['image'] = this.image;
    data['name'] = this.name;
    data['description'] = this.description;
    data['images'] = this.images;
    data['in_favorites'] = this.inFavorites;
    data['in_cart'] = this.inCart;
    return data;
  }
}
Comment

json to dart

class ApiModel {
  int? userId;
  int? id;
  String? title;
  String? body;

  ApiModel({this.userId, this.id, this.title, this.body});

  ApiModel.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    id = json['id'];
    title = json['title'];
    body = json['body'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = this.userId;
    data['id'] = this.id;
    data['title'] = this.title;
    data['body'] = this.body;
    return data;
  }
}
Comment

convert json to dart

class NewsDescriptionModel {
  NewsDetail? newsDetail;
  String? editorList;
  List<Tags>? tags;

  NewsDescriptionModel({this.newsDetail, this.editorList, this.tags});

  NewsDescriptionModel.fromJson(Map<String, dynamic> json) {
    newsDetail = json['NewsDetail'] != null
        ? new NewsDetail.fromJson(json['NewsDetail'])
        : null;
    editorList = json['editorList'];
    if (json['tags'] != null) {
      tags = <Tags>[];
      json['tags'].forEach((v) {
        tags!.add(new Tags.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.newsDetail != null) {
      data['NewsDetail'] = this.newsDetail!.toJson();
    }
    data['editorList'] = this.editorList;
    if (this.tags != null) {
      data['tags'] = this.tags!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class NewsDetail {
  String? id;
  String? source;
  String? author;
  String? title;
  String? timestamp;
  String? section;
  String? slug;
  String? sectionId;
  String? content;
  String? websiteurl;
  String? thumbnailUrl;
  String? sectionUrl;
  String? url;
  String? newsType;
  String? highlights;
  String? comments;

  NewsDetail(
      {this.id,
      this.source,
      this.author,
      this.title,
      this.timestamp,
      this.section,
      this.slug,
      this.sectionId,
      this.content,
      this.websiteurl,
      this.thumbnailUrl,
      this.sectionUrl,
      this.url,
      this.newsType,
      this.highlights,
      this.comments});

  NewsDetail.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    source = json['source'];
    author = json['author'];
    title = json['title'];
    timestamp = json['timestamp'];
    section = json['section'];
    slug = json['slug'];
    sectionId = json['section_id'];
    content = json['content'];
    websiteurl = json['websiteurl'];
    thumbnailUrl = json['thumbnail_url'];
    sectionUrl = json['section_url'];
    url = json['url'];
    newsType = json['news_type'];
    highlights = json['highlights'];
    comments = json['comments'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['source'] = this.source;
    data['author'] = this.author;
    data['title'] = this.title;
    data['timestamp'] = this.timestamp;
    data['section'] = this.section;
    data['slug'] = this.slug;
    data['section_id'] = this.sectionId;
    data['content'] = this.content;
    data['websiteurl'] = this.websiteurl;
    data['thumbnail_url'] = this.thumbnailUrl;
    data['section_url'] = this.sectionUrl;
    data['url'] = this.url;
    data['news_type'] = this.newsType;
    data['highlights'] = this.highlights;
    data['comments'] = this.comments;
    return data;
  }
}

class Tags {
  String? title;
  int? topicID;
  String? sectionPageURL;

  Tags({this.title, this.topicID, this.sectionPageURL});

  Tags.fromJson(Map<String, dynamic> json) {
    title = json['title'];
    topicID = json['topicID'];
    sectionPageURL = json['sectionPageURL'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['title'] = this.title;
    data['topicID'] = this.topicID;
    data['sectionPageURL'] = this.sectionPageURL;
    return data;
  }
}
Comment

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;
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript null 
Javascript :: download in react 
Javascript :: null check in javascript 
Javascript :: what is heap in javascript 
Javascript :: dynamic key in javascript object 
Javascript :: vuetify select array 
Javascript :: fetch timeout 
Javascript :: javascript two dimensional array 
Javascript :: usereducer in react 
Javascript :: javascript sandbox 
Javascript :: how to prevent previous radio button active react native 
Javascript :: Texto unitário no node js 
Javascript :: insert property in json file with bash 
Javascript :: how to delete props from url 
Javascript :: rect js 
Javascript :: cuantos docentes hay en mexico 
Javascript :: elon musk 4k photo 
Javascript :: find smallest interval in array javascript 
Javascript :: onpress react native datepicker stackver flow 
Javascript :: imagemagick javascript 
Javascript :: “new Set” is returning an empty set in nodejs 
Javascript :: short in javascript 
Javascript :: jquery select2 tab open 
Javascript :: nodejs optimizing compuler try catch 
Javascript :: what is es11 
Javascript :: 231105 color 
Javascript :: auto increment string in javascript 
Javascript :: LogRocket 
Javascript :: check textbox value on ng-change value == in angular 
Javascript :: callback in response node.js 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =