xxxxxxxxxx
class NewsModel {
String? status;
int? totalResults;
List<Articles>? articles;
NewsModel({this.status, this.totalResults, this.articles});
NewsModel.fromJson(Map<String, dynamic> json) {
status = json['status'];
totalResults = json['totalResults'];
if (json['articles'] != null) {
articles = <Articles>[];
json['articles'].forEach((v) {
articles!.add(new Articles.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
data['totalResults'] = this.totalResults;
if (this.articles != null) {
data['articles'] = this.articles!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Articles {
Source? source;
String? author;
String? title;
String? description;
String? url;
String? urlToImage;
String? publishedAt;
String? content;
Articles(
{this.source,
this.author,
this.title,
this.description,
this.url,
this.urlToImage,
this.publishedAt,
this.content});
Articles.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 {
String? 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 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;
}
}
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 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;
}
}