erjson 0.1.0

A simple rust json parser
Documentation
  • Coverage
  • 0%
    0 out of 18 items documented0 out of 6 items with examples
  • Size
  • Source code size: 30.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • evanxg852000/erjson
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • evanxg852000

erjson: A simple rust json parser

Examples

use erjson::{ JSONDocument, JSONValue };

fn main() {
  let data = r#"{
    "name": "John Doe",
    "age": 43,
    "props": { "weight": 76, "height": 2.3 },
    "primes": [ 11, 13, 17, 19, 23 ],
    "colors": [ "red", "blue" ]
  }"#;

  let json = String::from(data);
  let mut doc = JSONDocument::new();
  match doc.parse_string(json) {
    Ok(ref mut v) => {
      println!("name: {}", v.get("name").unwrap()); // John Doe
      println!("age: {}", v.get("age").unwrap()); // 43
      match v {
        JSONValue::Object(hm) => {
          *hm.get_mut("age").unwrap() = JSONValue::Number(45f64);
        }
        _ => {}
      };
      println!("age: {}", v.get("age").unwrap()); // 45
    },
    Err(err) => print!("err: {}", err)
  }

}