AnalysisUpdateContentParams.fromJson constructor

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

Implementation

factory AnalysisUpdateContentParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    Map<String, Object> files;
    if (json.containsKey('files')) {
      files = jsonDecoder.decodeMap(
        '$jsonPath.files',
        json['files'],
        keyDecoder: (String jsonPath, Object? json) =>
            clientUriConverter?.fromClientFilePath(
              jsonDecoder.decodeString(jsonPath, json),
            ) ??
            jsonDecoder.decodeString(jsonPath, json),
        valueDecoder: (String jsonPath, Object? json) =>
            jsonDecoder.decodeUnion(jsonPath, json, 'type', {
              'add': (String jsonPath, Object? json) =>
                  AddContentOverlay.fromJson(
                    jsonDecoder,
                    jsonPath,
                    json,
                    clientUriConverter: clientUriConverter,
                  ),
              'change': (String jsonPath, Object? json) =>
                  ChangeContentOverlay.fromJson(
                    jsonDecoder,
                    jsonPath,
                    json,
                    clientUriConverter: clientUriConverter,
                  ),
              'remove': (String jsonPath, Object? json) =>
                  RemoveContentOverlay.fromJson(
                    jsonDecoder,
                    jsonPath,
                    json,
                    clientUriConverter: clientUriConverter,
                  ),
            }),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, "'files'", json);
    }
    return AnalysisUpdateContentParams(files);
  } else {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.updateContent params'",
      json,
    );
  }
}