LinkedEditGroup.fromJson constructor

LinkedEditGroup.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory LinkedEditGroup.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'LinkedEditGroup'", json);
  }
  List<Position> positions;
  if (json case {'positions': var encodedPositions}) {
    positions = jsonDecoder.decodeList(
      '$jsonPath.positions',
      encodedPositions,
      (String jsonPath, Object? json) => Position.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'positions'", json);
  }
  int length;
  if (json case {'length': var encodedLength}) {
    length = jsonDecoder.decodeInt('$jsonPath.length', encodedLength);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'length'", json);
  }
  List<LinkedEditSuggestion> suggestions;
  if (json case {'suggestions': var encodedSuggestions}) {
    suggestions = jsonDecoder.decodeList(
      '$jsonPath.suggestions',
      encodedSuggestions,
      (String jsonPath, Object? json) => LinkedEditSuggestion.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'suggestions'", json);
  }
  return LinkedEditGroup(positions, length, suggestions);
}