Module json

Module json 

Source
Expand description

JSON configuration parser.

This is only usable if you enabled json Cargo feature.

§Example

use plugx_config::parser::{Parser, json::Json};
use plugx_input::Input;

let bytes = br#"
{
    "hello": ["w", "o", "l", "d"],
    "foo": {
        "bar": {
            "baz": "Qux",
            "abc": 3.14
        },
        "xyz": false
    }
}
"#;

let parser = Json::new();
let parsed: Input = parser.parse(bytes.as_slice()).unwrap();

assert!(parsed.is_map());
let map = parsed.as_map();
assert!(
    map.len() == 2 &&
    map.contains_key("foo") &&
    map.contains_key("hello")
);

Structs§

Json