Skip to main content

read_through_json_value

Macro read_through_json_value 

Source
macro_rules! read_through_json_value {
    ($ty:ty) => { ... };
    ($ty:ty, custom) => { ... };
    ($ty:ty, write) => { ... };
    ($ty:ty, read) => { ... };
}
Expand description

Serde for a JSON-only type whose reading goes through one serde_json::Value.

The type derives with #[serde(remote = "Self")], which makes its derived code inherent functions. Writing runs them as derived. Reading runs them once, against a Value, in the crate that declares the type: every format and every crate that reads the type then shares that one copy instead of compiling the type’s whole deserializer (and, for an internally tagged enum, its buffered copy) again for each deserializer it meets. Only for types every encoding of which is JSON: a Value needs a self-describing format. custom leaves from_json_value to the type. write also writes through one Value, built by a function compiled in the declaring crate, so a crate that writes the type compiles none of its serializer either; the JSON is the same.