xxxxxxxxxx
import 'dart:convert';
class MyModel {
final int id;
final String name;
MyModel({required this.id, required this.name});
factory MyModel.fromJson(Map<String, dynamic> json) {
return MyModel(
id: json['id'],
name: json['name'],
);
}
}
void main() {
String jsonString = '{"id": 1, "name": "John Doe"}';
Map<String, dynamic> jsonMap = json.decode(jsonString);
MyModel model = MyModel.fromJson(jsonMap);
print(model.id); // Output: 1
print(model.name); // Output: John Doe
}
xxxxxxxxxx
class certification_model {
String? responseCode;
String? responseMessage;
String? companyName;
String? companyAddress;
String? companyNTN;
String? customerName;
String? issuanceDate;
String? nICNO;
String? totalTaxAmount;
String? totalTaxAmountWords;
String? dateFrom;
String? dateTo;
String? account;
String? totalTaxableAmount;
String? section;
List<CertificateDetails>? certificateDetails;
certification_model(
{this.responseCode,
this.responseMessage,
this.companyName,
this.companyAddress,
this.companyNTN,
this.customerName,
this.issuanceDate,
this.nICNO,
this.totalTaxAmount,
this.totalTaxAmountWords,
this.dateFrom,
this.dateTo,
this.account,
this.totalTaxableAmount,
this.section,
this.certificateDetails});
certification_model.fromJson(Map<String, dynamic> json) {
responseCode = json['ResponseCode'];
responseMessage = json['ResponseMessage'];
companyName = json['CompanyName'];
companyAddress = json['CompanyAddress'];
companyNTN = json['CompanyNTN'];
customerName = json['CustomerName'];
issuanceDate = json['IssuanceDate'];
nICNO = json['NIC_NO'];
totalTaxAmount = json['TotalTaxAmount'];
totalTaxAmountWords = json['TotalTaxAmountWords'];
dateFrom = json['DateFrom'];
dateTo = json['DateTo'];
account = json['Account'];
totalTaxableAmount = json['TotalTaxableAmount'];
section = json['Section'];
if (json['CertificateDetails'] != null) {
certificateDetails = <CertificateDetails>[];
json['CertificateDetails'].forEach((v) {
certificateDetails!.add(new CertificateDetails.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ResponseCode'] = this.responseCode;
data['ResponseMessage'] = this.responseMessage;
data['CompanyName'] = this.companyName;
data['CompanyAddress'] = this.companyAddress;
data['CompanyNTN'] = this.companyNTN;
data['CustomerName'] = this.customerName;
data['IssuanceDate'] = this.issuanceDate;
data['NIC_NO'] = this.nICNO;
data['TotalTaxAmount'] = this.totalTaxAmount;
data['TotalTaxAmountWords'] = this.totalTaxAmountWords;
data['DateFrom'] = this.dateFrom;
data['DateTo'] = this.dateTo;
data['Account'] = this.account;
data['TotalTaxableAmount'] = this.totalTaxableAmount;
data['Section'] = this.section;
if (this.certificateDetails != null) {
data['CertificateDetails'] =
this.certificateDetails!.map((v) => v.toJson()).toList();
}
return data;
}
}
class CertificateDetails {
String? cPR;
String? amount;
CertificateDetails({this.cPR, this.amount});
CertificateDetails.fromJson(Map<String, dynamic> json) {
cPR = json['CPR'];
amount = json['Amount'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['CPR'] = this.cPR;
data['Amount'] = this.amount;
return data;
}
}
xxxxxxxxxx
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;
}
}
xxxxxxxxxx
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;
}
}
xxxxxxxxxx
class Model {
String? name;
Model({this.name});
Model.fromJson(Map<String, dynamic> json) {
name = json['Name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['Name'] = this.name;
return data;
}
}
xxxxxxxxxx
import 'dart:convert';
void main() {
String jsonStr = '{"name": "John", "age": 30}'; // Example JSON data
Map<String, dynamic> jsonMap = jsonDecode(jsonStr); // Parse JSON string to a map
Person person = Person.fromJson(jsonMap); // Convert the map to a Dart class object
print(person.name); // Access the object's properties
print(person.age);
}
class Person {
String name;
int age;
Person({this.name, this.age});
// Factory method to create a Person object from a map
factory Person.fromJson(Map<String, dynamic> json) {
return Person(
name: json['name'],
age: json['age'],
);
}
}
xxxxxxxxxx
// [{
// "source": {
// "id": null,
// "name": "Lifehacker.com"
// },
// "author": "Khamosh Pathak",
// "title": "The Best Prime Day Deals on Laptops",
// "description": "Amazon’s Prime Day sale is upon us, and there are quite a lot of laptop bargains to go around, from everyday college laptops, to MacBooks, and even high-end gaming machines. If you are in the market for a laptop, or were planning to buy one soon, this is a gr…",
// "url": "https://lifehacker.com/the-best-prime-day-deals-on-laptops-1850627675",
// "urlToImage": "https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/8871e886aadcc852f7d15318ac57bef8.jpg",
// "publishedAt": "2023-07-11T22:15:00Z",
// "content": "Amazons Prime Day sale is upon us, and there are quite a lot of laptop bargains to go around, from everyday college laptops, to MacBooks, and even high-end gaming machines. If you are in the market f… [+3211 chars]"
// }]
class NewsModel {
Source? source;
String? author;
String? title;
String? description;
String? url;
String? urlToImage;
String? publishedAt;
String? content;
NewsModel(
{this.source,
this.author,
this.title,
this.description,
this.url,
this.urlToImage,
this.publishedAt,
this.content});
NewsModel.fromJson(Map<String, dynamic> json) {
source =
json['source'] != null ? new Source.fromJson(json['source']) : null;
author = json['author'];
title = json['title'];
description = json['description'];
url = json['url'];
urlToImage = json['urlToImage'];
publishedAt = json['publishedAt'];
content = json['content'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.source != null) {
data['source'] = this.source!.toJson();
}
data['author'] = this.author;
data['title'] = this.title;
data['description'] = this.description;
data['url'] = this.url;
data['urlToImage'] = this.urlToImage;
data['publishedAt'] = this.publishedAt;
data['content'] = this.content;
return data;
}
}
class Source {
Null? id;
String? name;
Source({this.id, this.name});
Source.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
xxxxxxxxxx
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;
}
}
xxxxxxxxxx
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;
}
}
xxxxxxxxxx
class getProductListFromAPI {
String? status;
List<Data>? data;
getProductListFromAPI({this.status, this.data});
getProductListFromAPI.fromJson(Map<String, dynamic> json) {
status = json['status'];
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['status'] = this.status;
if (this.data != null) {
data['data'] = this.data!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Data {
String? sId;
String? productName;
String? productCode;
String? img;
String? unitPrice;
String? qty;
String? totalPrice;
String? createdDate;
Data(
{this.sId,
this.productName,
this.productCode,
this.img,
this.unitPrice,
this.qty,
this.totalPrice,
this.createdDate});
Data.fromJson(Map<String, dynamic> json) {
sId = json['_id'];
productName = json['ProductName'];
productCode = json['ProductCode'];
img = json['Img'];
unitPrice = json['UnitPrice'];
qty = json['Qty'];
totalPrice = json['TotalPrice'];
createdDate = json['CreatedDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['_id'] = this.sId;
data['ProductName'] = this.productName;
data['ProductCode'] = this.productCode;
data['Img'] = this.img;
data['UnitPrice'] = this.unitPrice;
data['Qty'] = this.qty;
data['TotalPrice'] = this.totalPrice;
data['CreatedDate'] = this.createdDate;
return data;
}
}
xxxxxxxxxx
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;
}
}