SearchResult.fromJson constructor
SearchResult.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory SearchResult.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
Location location;
if (json.containsKey('location')) {
location = Location.fromJson(
jsonDecoder, '$jsonPath.location', json['location']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'location');
}
SearchResultKind kind;
if (json.containsKey('kind')) {
kind = SearchResultKind.fromJson(
jsonDecoder, '$jsonPath.kind', json['kind']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'kind');
}
bool isPotential;
if (json.containsKey('isPotential')) {
isPotential = jsonDecoder.decodeBool(
'$jsonPath.isPotential', json['isPotential']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'isPotential');
}
List<Element> path;
if (json.containsKey('path')) {
path = jsonDecoder.decodeList(
'$jsonPath.path',
json['path'],
(String jsonPath, Object? json) =>
Element.fromJson(jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'path');
}
return SearchResult(location, kind, isPotential, path);
} else {
throw jsonDecoder.mismatch(jsonPath, 'SearchResult', json);
}
}