Element.fromJson constructor
Element.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory Element.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
ElementKind kind;
if (json.containsKey('kind')) {
kind =
ElementKind.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');
}
Location? location;
if (json.containsKey('location')) {
location = Location.fromJson(
jsonDecoder, '$jsonPath.location', json['location']);
}
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);
}
}