toJson method

Map toJson()

Serialize instance to JSON Object

Implementation

Map toJson() {
  Map fromObject = {
    "accuracyRadius": accuracyRadius,
    "latitude": latitude,
    "longitude": longitude,
    "postalCode": postalCode,
    "timezone": timezone,
    "city": city?.toJson(),
    "country": country?.toJson(),
    "continent": continent?.toJson(),
    "subdivisions":
        subdivisions?.map((subdivision) => subdivision.toJson()).toList(),
  };

  fromObject.removeWhere((key, value) => value == null);

  return fromObject;
}