123 lines
3.0 KiB
Dart
123 lines
3.0 KiB
Dart
|
// To parse this JSON data, do
|
||
|
//
|
||
|
// final barangay = barangayFromJson(jsonString);
|
||
|
|
||
|
import 'package:meta/meta.dart';
|
||
|
import 'dart:convert';
|
||
|
|
||
|
Barangay barangayFromJson(String str) => Barangay.fromJson(json.decode(str));
|
||
|
|
||
|
String barangayToJson(Barangay data) => json.encode(data.toJson());
|
||
|
|
||
|
class Barangay {
|
||
|
Barangay({
|
||
|
required this.code,
|
||
|
required this.description,
|
||
|
required this.cityMunicipality,
|
||
|
});
|
||
|
|
||
|
final String code;
|
||
|
final String description;
|
||
|
final CityMunicipality cityMunicipality;
|
||
|
|
||
|
factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
|
||
|
code: json["code"],
|
||
|
description: json["description"],
|
||
|
cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]),
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"code": code,
|
||
|
"description": description,
|
||
|
"city_municipality": cityMunicipality.toJson(),
|
||
|
};
|
||
|
}
|
||
|
|
||
|
class CityMunicipality {
|
||
|
CityMunicipality({
|
||
|
required this.code,
|
||
|
required this.description,
|
||
|
required this.province,
|
||
|
required this.psgcCode,
|
||
|
required this.zipcode,
|
||
|
});
|
||
|
|
||
|
final String code;
|
||
|
final String description;
|
||
|
final Province province;
|
||
|
final String psgcCode;
|
||
|
final String zipcode;
|
||
|
|
||
|
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
|
||
|
code: json["code"],
|
||
|
description: json["description"],
|
||
|
province: Province.fromJson(json["province"]),
|
||
|
psgcCode: json["psgc_code"],
|
||
|
zipcode: json["zipcode"],
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"code": code,
|
||
|
"description": description,
|
||
|
"province": province.toJson(),
|
||
|
"psgc_code": psgcCode,
|
||
|
"zipcode": zipcode,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
class Province {
|
||
|
Province({
|
||
|
required this.code,
|
||
|
required this.description,
|
||
|
required this.region,
|
||
|
required this.psgcCode,
|
||
|
required this.shortname,
|
||
|
});
|
||
|
|
||
|
final String code;
|
||
|
final String description;
|
||
|
final Region region;
|
||
|
final String psgcCode;
|
||
|
final String shortname;
|
||
|
|
||
|
factory Province.fromJson(Map<String, dynamic> json) => Province(
|
||
|
code: json["code"],
|
||
|
description: json["description"],
|
||
|
region: Region.fromJson(json["region"]),
|
||
|
psgcCode: json["psgc_code"],
|
||
|
shortname: json["shortname"],
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"code": code,
|
||
|
"description": description,
|
||
|
"region": region.toJson(),
|
||
|
"psgc_code": psgcCode,
|
||
|
"shortname": shortname,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
class Region {
|
||
|
Region({
|
||
|
required this.code,
|
||
|
required this.description,
|
||
|
required this.psgcCode,
|
||
|
});
|
||
|
|
||
|
final int code;
|
||
|
final String description;
|
||
|
final String psgcCode;
|
||
|
|
||
|
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
||
|
code: json["code"],
|
||
|
description: json["description"],
|
||
|
psgcCode: json["psgc_code"],
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"code": code,
|
||
|
"description": description,
|
||
|
"psgc_code": psgcCode,
|
||
|
};
|
||
|
}
|