Expand description
TreeSerialize
/TreeDeserialize
with “JSON and /
”.
Access items with '/'
as path separator and JSON (from serde-json-core
)
as serialization/deserialization payload format.
Paths used here are reciprocal to TreeSchema::lookup::<Path<_, '/'>, _>(...)
/
TreeSchema::SCHEMA.nodes::<Path<_, '/'>>()
.
use miniconf::{json_core, Tree};
#[derive(Tree, Default)]
struct S {
foo: u32,
bar: [u16; 2],
};
let mut s = S::default();
json_core::set(&mut s, "/bar/1", b"9").unwrap();
assert_eq!(s.bar[1], 9);
let mut buf = [0u8; 10];
let len = json_core::get(&mut s, "/bar/1", &mut buf[..]).unwrap();
assert_eq!(&buf[..len], b"9");
Functions§
- get
- Retrieve a serialized value by path.
- get_
by_ key - Retrieve a serialized value by key.
- set
- Update a node by path.
- set_
by_ key - Update a node by key.