json_util library

JSON utilities for Dart.

Classes

DecodedValue
The direct result of some JSON decoding.
EncodableValue
A candidate for direct JSON encoding.

Functions

convertDecode(String source, {Reviver? reviver}) → dynamic
Parses the string and returns the resulting Json object.
convertEncode(Object? value, {ToEncodable? toEncodable}) String
Converts value to a JSON string.

Typedefs

ObjectEncoder<N, E> = E Function(N nonEncodableObject)
A function that creates an object of the type E starting from one of the type N.
ObjectTransformer<E, T> = T Function(E encodedObject)
A function that creates an object of the type T starting from one of the type E.
Reviver = Object? Function(Object? key, Object? value)
Used to "revive" an object previously encoded into some JSON data.
ToEncodable = Object? Function(Object? nonEncodable)
Used to encode an object not directly encodable into some JSON data.

Exceptions / Errors

DecodedValueError
Signature for a generic error thrown by DecodedValue.
EncodableValueError
Signature for a generic error thrown by EncodableValue.
JsonCastingError
Error thrown during a JSON casting operation.
JsonCheckingError
Error thrown during a JSON checking operation.
JsonDecodingError
Error thrown during a JSON decoding operation.
JsonEncodingError
Error thrown during a JSON encoding operation.
JsonExtractionError
Error thrown during a JSON extraction operation.
JsonFormatException
Exception thrown when a string does not have the expected JSON format and cannot be parsed.
JsonPreparationError
Error thrown during a JSON preparation operation.
JsonTransformationError
Error thrown during a JSON transformation operation.