models/util/json_value library

Functions

convertJsonValue<T>(Object? raw) → T?
Converts a raw JSON value to T, or returns null when that would lose or invent data, e.g. "7" to 7.
decodeJsonText(Object? raw) → Object?
Decodes raw when it's JSON sent as text, e.g. '{"a": 1}' to a map; anything else comes back unchanged.
toJsonValue(Object? value) → Object?
Converts value to plain JSON: nested models become maps, dates ISO text and enums their name.