Occurrences.fromJson constructor
Occurrences.fromJson(})
Implementation
factory Occurrences.fromJson(
JsonDecoder jsonDecoder,
String jsonPath,
Object? json, {
ClientUriConverter? clientUriConverter,
}) {
json ??= {};
if (json is! Map) {
throw jsonDecoder.mismatch(jsonPath, "'Occurrences'", json);
}
Element element;
if (json case {'element': var encodedElement}) {
element = Element.fromJson(
jsonDecoder,
'$jsonPath.element',
encodedElement,
clientUriConverter: clientUriConverter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'element'", json);
}
List<int> offsets;
if (json case {'offsets': var encodedOffsets}) {
offsets = jsonDecoder.decodeList(
'$jsonPath.offsets',
encodedOffsets,
jsonDecoder.decodeInt,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'offsets'", json);
}
int length;
if (json case {'length': var encodedLength}) {
length = jsonDecoder.decodeInt('$jsonPath.length', encodedLength);
} else {
throw jsonDecoder.mismatch(jsonPath, "'length'", json);
}
return Occurrences(element, offsets, length);
}