ResourceDescriptor.fromJson constructor

ResourceDescriptor.fromJson(
  1. Object? j
)

Implementation

factory ResourceDescriptor.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return ResourceDescriptor(
    type: switch (json['type']) {
      null => '',
      Object $1 => decodeString($1),
    },
    pattern: switch (json['pattern']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"pattern" is not a list'),
    },
    nameField: switch (json['nameField']) {
      null => '',
      Object $1 => decodeString($1),
    },
    history: switch (json['history']) {
      null => ResourceDescriptor_History.$default,
      Object $1 => ResourceDescriptor_History.fromJson($1),
    },
    plural: switch (json['plural']) {
      null => '',
      Object $1 => decodeString($1),
    },
    singular: switch (json['singular']) {
      null => '',
      Object $1 => decodeString($1),
    },
    style: switch (json['style']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) ResourceDescriptor_Style.fromJson(i),
      ],
      _ => throw const FormatException('"style" is not a list'),
    },
  );
}