fromJson static method
Returns a new SFULocationResponse instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SFULocationResponse? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'coordinates'),
'Required key "SFULocationResponse[coordinates]" is missing from JSON.');
assert(json[r'coordinates'] != null,
'Required key "SFULocationResponse[coordinates]" has a null value in JSON.');
assert(json.containsKey(r'datacenter'),
'Required key "SFULocationResponse[datacenter]" is missing from JSON.');
assert(json[r'datacenter'] != null,
'Required key "SFULocationResponse[datacenter]" has a null value in JSON.');
assert(json.containsKey(r'id'),
'Required key "SFULocationResponse[id]" is missing from JSON.');
assert(json[r'id'] != null,
'Required key "SFULocationResponse[id]" has a null value in JSON.');
assert(json.containsKey(r'location'),
'Required key "SFULocationResponse[location]" is missing from JSON.');
assert(json[r'location'] != null,
'Required key "SFULocationResponse[location]" has a null value in JSON.');
return true;
}());
return SFULocationResponse(
coordinates: CoordinatesResponse.fromJson(json[r'coordinates'])!,
count: mapValueOfType<int>(json, r'count'),
datacenter: mapValueOfType<String>(json, r'datacenter')!,
id: mapValueOfType<String>(json, r'id')!,
location: LocationResponse.fromJson(json[r'location'])!,
);
}
return null;
}