JsonValue extension type
A zero-cost wrapper around any JSON value including null
.
This type mostly exists to provide a common supertype for all JSON values, but otherwise has no behavior or properties of its own. To model an object that intentionally is unknown (could be any type of JSON value), see the JsonAny type (and asAny).
Safety
It is undefined behavior to cast (i.e. using as
or a similar method such
as List.cast) an Object to a JsonValue if it is not a valid JSON
value.
For example, casting a Duration to a JsonValue fails during encoding:
import 'dart:convert';
import 'package:jsonut/jsonut.dart';
void main() {
final value = Duration(seconds: 1);
jsonEncode(value); // Throws
}
See also:
- JsonBoolean
- JsonNumber
- JsonString
- JsonArray
- JsonObject
- JsonAny and
JsonAny.from
- jsonNull
- on
- Implementers