wson 0.1.1

JSON parser made with nom
Documentation
  • Coverage
  • 23.08%
    6 out of 26 items documented4 out of 11 items with examples
  • Size
  • Source code size: 30.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.84 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wat-aro/wson
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wat-aro

wson

JSON parser made with nom.

Usage

let value = parse(
    "{\"menu\": {
       \"id\": \"file\",
       \"value\": \"File\",
       \"popup\": {
         \"menuitem\": [
           {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},
           {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},
           {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}
         ]
       }
    }}",
)?;
let expected = Value::Object(HashMap::from([(
    "menu".to_string(),
    Value::Object(HashMap::from([
        ("id".to_string(), Value::String("file".to_string())),
        ("value".to_string(), Value::String("File".to_string())),
        (
            "popup".to_string(),
            Value::Object(HashMap::from([(
                "menuitem".to_string(),
                Value::Array(vec![
                    Value::Object(HashMap::from([
                        ("value".to_string(), Value::String("New".to_string())),
                        (
                            "onclick".to_string(),
                            Value::String("CreateNewDoc()".to_string()),
                        ),
                    ])),
                    Value::Object(HashMap::from([
                        ("value".to_string(), Value::String("Open".to_string())),
                        (
                            "onclick".to_string(),
                            Value::String("OpenDoc()".to_string()),
                        ),
                    ])),
                    Value::Object(HashMap::from([
                        ("value".to_string(), Value::String("Close".to_string())),
                        (
                            "onclick".to_string(),
                            Value::String("CloseDoc()".to_string()),
                        ),
                    ])),
                ]),
            )])),
        ),
    ])),
)]));
assert_eq!(value, expected);

Installation

[dependencies]
wson = "*"