ParameterInfo.fromJson constructor

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

Implementation

factory ParameterInfo.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    ParameterKind kind;
    if (json.containsKey('kind')) {
      kind =
          ParameterKind.fromJson(jsonDecoder, '$jsonPath.kind', json['kind']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'kind');
    }
    String name;
    if (json.containsKey('name')) {
      name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'name');
    }
    String type;
    if (json.containsKey('type')) {
      type = jsonDecoder.decodeString('$jsonPath.type', json['type']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'type');
    }
    String? defaultValue;
    if (json.containsKey('defaultValue')) {
      defaultValue = jsonDecoder.decodeString(
          '$jsonPath.defaultValue', json['defaultValue']);
    }
    return ParameterInfo(kind, name, type, defaultValue: defaultValue);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ParameterInfo', json);
  }
}