Crates.io | sppparse |
lib.rs | sppparse |
version | 0.1.4 |
source | src |
created_at | 2021-01-18 16:56:02.360373 |
updated_at | 2021-05-02 20:45:18.202232 |
description | Sparsed pointer parser for JSON/YAML |
homepage | |
repository | https://github.com/basiliqio/sppparse |
max_upload_size | |
id | 343577 |
size | 118,701 |
Modern JSON
/YAML
tends to use JSON Pointer. This crate aims to facilitate their use.
Built on top of serde, this library allows a generic way to read and modify documents containing $ref
.
The following features are available :
url
: Add support for url::Url
semver
: Add support for semver::Version
#[derive(Debug, Deserialize, Serialize, Sparsable)]
struct ObjectExampleParsed {
hello: String,
obj: HashMap<String, SparseSelector<String>>,
}
fn main() {
let json_value = json!({
"hello": "world",
"obj": {
"key1": {
"$ref": "#/hello"
}
}
});
let parsed_obj: SparseRoot<ObjectExampleParsed> =
SparseRoot::new_from_value(json_value, PathBuf::from("hello.json"), vec![]).unwrap();
println!(
"{}",
parsed_obj
.root_get()
.unwrap()
.obj
.get("key1")
.unwrap()
.get()
.expect("the dereferenced pointer")
);
}
// Prints "world"