sppparse_derive

Crates.iosppparse_derive
lib.rssppparse_derive
version0.1.3
sourcesrc
created_at2021-01-18 16:50:01.456389
updated_at2021-05-02 20:44:45.1416
descriptionDerive macro for Sppparse
homepage
repositoryhttps://github.com/basiliqio/sppparse
max_upload_size
id343575
size3,595
Francis Le Roy (GrandChaman)

documentation

README

Sppparse (Sparsed Pointer Parser)

Introduction

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.

Features

The following features are available :

  • url: Add support for url::Url
  • semver: Add support for semver::Version

Example

#[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"
Commit count: 91

cargo fmt