DiagnosticGetDiagnosticsResult.fromJson constructor

DiagnosticGetDiagnosticsResult.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory DiagnosticGetDiagnosticsResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    List<ContextData> contexts;
    if (json.containsKey('contexts')) {
      contexts = jsonDecoder.decodeList(
          '$jsonPath.contexts',
          json['contexts'],
          (String jsonPath, Object? json) =>
              ContextData.fromJson(jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'contexts');
    }
    return DiagnosticGetDiagnosticsResult(contexts);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'diagnostic.getDiagnostics result', json);
  }
}