parse<T extends JsonValue?> static method

T parse<T extends JsonValue?>(
  1. String json
)

Parses the given json string into a typed JSON value.

If parsing fails, a FormatException is thrown.

Implementation

static T parse<T extends JsonValue?>(String json) {
  final value = dart.json.decode(json);
  if (value is T) {
    return value;
  }
  throw FormatException(
    'Decoded value is ${JsonValue._typeToString(value.runtimeType)}, '
    'expected ${JsonValue._typeToString(T)}',
    json,
  );
}