Element.fromJson constructor

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

Implementation

factory Element.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    ElementKind kind;
    if (json.containsKey('kind')) {
      kind = ElementKind.fromJson(
        jsonDecoder,
        '$jsonPath.kind',
        json['kind'],
        clientUriConverter: clientUriConverter,
      );
    } 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');
    }
    Location? location;
    if (json.containsKey('location')) {
      location = Location.fromJson(
        jsonDecoder,
        '$jsonPath.location',
        json['location'],
        clientUriConverter: clientUriConverter,
      );
    }
    int flags;
    if (json.containsKey('flags')) {
      flags = jsonDecoder.decodeInt('$jsonPath.flags', json['flags']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'flags');
    }
    String? parameters;
    if (json.containsKey('parameters')) {
      parameters = jsonDecoder.decodeString(
        '$jsonPath.parameters',
        json['parameters'],
      );
    }
    String? returnType;
    if (json.containsKey('returnType')) {
      returnType = jsonDecoder.decodeString(
        '$jsonPath.returnType',
        json['returnType'],
      );
    }
    String? typeParameters;
    if (json.containsKey('typeParameters')) {
      typeParameters = jsonDecoder.decodeString(
        '$jsonPath.typeParameters',
        json['typeParameters'],
      );
    }
    String? aliasedType;
    if (json.containsKey('aliasedType')) {
      aliasedType = jsonDecoder.decodeString(
        '$jsonPath.aliasedType',
        json['aliasedType'],
      );
    }
    return Element(
      kind,
      name,
      flags,
      location: location,
      parameters: parameters,
      returnType: returnType,
      typeParameters: typeParameters,
      aliasedType: aliasedType,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'Element', json);
  }
}