Type.fromJson constructor

Type.fromJson(
  1. Object? j
)

Implementation

factory Type.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return Type(
    name: switch (json['name']) {
      null => '',
      Object $1 => decodeString($1),
    },
    fields: switch (json['fields']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Field.fromJson(i)],
      _ => throw const FormatException('"fields" is not a list'),
    },
    oneofs: switch (json['oneofs']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"oneofs" is not a list'),
    },
    options: switch (json['options']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Option.fromJson(i)],
      _ => throw const FormatException('"options" is not a list'),
    },
    sourceContext: switch (json['sourceContext']) {
      null => null,
      Object $1 => SourceContext.fromJson($1),
    },
    syntax: switch (json['syntax']) {
      null => Syntax.$default,
      Object $1 => Syntax.fromJson($1),
    },
    edition: switch (json['edition']) {
      null => '',
      Object $1 => decodeString($1),
    },
  );
}