Expand description
JSON encoding for stmt::Values stored in document-backed columns.
JSON encoding for stmt::Values stored in document-backed columns
(MySQL JSON, SQLite TEXT via the JSON1 extension, and eventually
PostgreSQL jsonb for #[document]-marked fields). The conversion is
intentionally a plain pair of functions rather than a Serialize /
Deserialize impl on stmt::Value: the encoding is opinionated
(UUIDs / decimals / timestamps as JSON strings) and matches the
per-column TEXT encoding the same scalar would have at the SQL level.
Backends with typed document storage (BSON, DynamoDB) need different
representations.
Decoding requires the element type from the schema — Value::Uuid vs
Value::String are both JSON strings on the wire, and only the
caller’s stmt::Type distinguishes them.
Functions§
- value_
from_ json - Decode a
serde_json::Valueinto astmt::Valueof typety. - value_
list_ from_ json - Decode a JSON array document into a
Value::List, usingelem_tyas the per-element type. - value_
list_ to_ json - Encode a
Value::Listas a JSON array document. The element type drives per-element encoding viavalue_to_json. - value_
to_ json - Encode a scalar
stmt::Valueas aserde_json::Value. Panics on shapes that have no JSON representation (Record, nestedList,Bytes,SparseRecord,Nullrecords, NaN / infinity).