arson 0.2.1

arson is a simple rust json library for parsing string. it has nice formatted colored output
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented1 out of 1 items with examples
  • Size
  • Source code size: 17.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.37 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
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hermanbrunborg

arson

arson is a simple rust json library for parsing string. it has nice formatted colored output


Cargo.toml

[dependencies]
arson = "x.x"

Example

use arson::{JSONError, Parser, JSON, JSON::*};

fn main() -> Result<(), JSONError> {
    // alternative A
    let json_str = std::fs::read_to_string("ex.json").unwrap();
    // alternative B
    let json_str = r#"{
        "name": "John Doe",
        "age": 43,
        "address": {
            "street": "10 Downing Street",
            "city": "London"
        },
        "phones": [
            "+44 1234567",
            "+44 2345678"
        ]
    } "#;

    // alternative 1
    let json = json_str.parse::<JSON>().expect("Failed to parse json");
    // alternative 2
    let json = Parser::parse(json_str.chars())?;

    println!("{:?}", json);

    match json {
        Array(val) => {}  // Vec<JSON>
        Object(val) => {} // HashMap<String, JSON>
        String(val) => {} // String
        Number(val) => {} // f64
        Bool(val) => {}   // bool
        Null => {}
    }

    Ok(())
}

Output

{
    "address": {
        "city": "London",
        "street": "10 Downing Street",
    },
    "name": "John Doe",
    "age": 43,
    "phones": [
        +44 1234567,
        +44 2345678,
    ],
}