import 'dart:convert'; T? asT(dynamic value) { if (value is T) { return value; } return null; } class NovelLatestModel { NovelLatestModel({ required this.id, required this.title, this.authors, this.cover, this.hotHits, this.lastName, this.status, this.types, this.subNums, }); factory NovelLatestModel.fromJson(Map json) => NovelLatestModel( id: asT(json['id'])!, title: asT(json['title'])!, authors: asT(json['authors']), cover: asT(json['cover']), hotHits: asT(json['hot_hits']), lastName: asT(json['last_name']), status: asT(json['status']), types: asT(json['types']), subNums: asT(json['sub_nums']), ); int id; String title; String? authors; String? cover; int? hotHits; String? lastName; String? status; String? types; int? subNums; @override String toString() { return jsonEncode(this); } Map toJson() => { 'id': id, 'title': title, 'authors': authors, 'cover': cover, 'hot_hits': hotHits, 'last_name': lastName, 'status': status, 'types': types, 'sub_nums': subNums, }; }