// To parse this JSON data, do // // final city = cityFromJson(jsonString); import 'dart:convert'; City cityFromJson(String str) => City.fromJson(json.decode(str)); String cityToJson(City data) => json.encode(data.toJson()); class City { final int? id; final String? cityCode; final String? cityDescription; final String? genCode; City({this.id, this.cityCode, this.cityDescription, this.genCode}); City copy( {int? id, String? cityCode, String? cityDescription, String? genCode}) { return City( id: id ?? this.id, cityCode: cityCode ?? this.cityCode, cityDescription: cityDescription ?? this.cityDescription, genCode: genCode ?? this.genCode, ); } factory City.fromJson(Map json) => City( id: json["id"], cityCode: json["city_code"], cityDescription: json["city_description"], genCode: json["gen_code"], ); factory City.fromJson2(Map json) => City( id: json["id"], cityCode: json["cityCode"], cityDescription: json["cityDescription"], genCode: json["genCode"]); Map toJson() => { "id": id, "city_code": cityCode, "city_description": cityDescription, "gen_code": genCode }; }