class MetalContentModel { List contents; int lastPage; MetalContentModel({required this.contents, required this.lastPage}); factory MetalContentModel.fromJson(Map json) { return MetalContentModel( contents: List.from( json['contents'].map((x) => MetalContent.fromJson(x))), lastPage: json['lastPage'], ); } Map toJson() { return { 'contents': List.from(contents.map((x) => x.toJson())), 'lastPage': lastPage, }; } } class MetalContent { final int id; final String label; final String title; final int type; final bool marked; final Data data; MetalContent({ required this.id, required this.label, required this.title, required this.type, required this.marked, required this.data, }); factory MetalContent.fromJson(Map json) { return MetalContent( id: json['id'], label: json['label'], title: json['title'], type: json['type'], marked: json['marked'], data: Data.fromJson(json['data']), ); } Map toJson() { return { 'id': id, 'label': label, 'title': title, 'type': type, 'marked': marked, 'data': data.toJson(), }; } } class Data { final String b1; final String b2; final String s1; final String s2; final String bc1; final String bc2; final String sc1; final String sc2; final String y; final String p; final String h; final String l; final String d; final double dp; final String dt; final String t; final String tEn; final String tG; final String ts; Data({ required this.b1, required this.b2, required this.s1, required this.s2, required this.bc1, required this.bc2, required this.sc1, required this.sc2, required this.y, required this.p, required this.h, required this.l, required this.d, required this.dp, required this.dt, required this.t, required this.tEn, required this.tG, required this.ts, }); factory Data.fromJson(Map json) { return Data( p: json['p'], h: json['h'], y: json['y'], l: json['l'], d: json['d'], dp: json['dp'].toDouble(), // Ensuring correct type dt: json['dt'], t: json['t'], tEn: json['t_en'], tG: json['t-g'], ts: json['ts'], b1: json['b1'].toString(), b2: json['b2'].toString(), s1: json['s1'].toString(), s2: json['s2'].toString(), bc1: json['bc1'].toString(), bc2: json['bc2'].toString(), sc1: json['sc1'].toString(), sc2: json['sc2'].toString(), ); } Map toJson() { return { 'p': p, 'h': h, 'l': l, "y": y, "b1": b1, "b2": b2, "s1": s1, "s2": s2, "bc1": bc1, "bc2": bc2, "sc1": sc1, "sc2": sc2, 'd': d, 'dp': dp, 'dt': dt, 't': t, 't_en': tEn, 't-g': tG, 'ts': ts, }; } }