#json #validation #validate #repair #serialization

nightly arya

simple json validation. simple json repair. lightning fast.

3 releases

0.0.3 Sep 26, 2018
0.0.2 Jul 7, 2018
0.0.1 Jul 7, 2018

#1788 in Encoding

MIT/Apache

52KB
477 lines

arya.

simple json validation. simple json repair. lightning fast.

example: json validation + repair.

let mut builder = JsonBuilder::new();

builder.update(r#"{
    "name": "annie",
    "age": 14,
    "parents": {
        "mother": null,
        "broken
"#);

builder.update("value");

builder.completed_string()

// => Ok({
// =>     "name": "annie",
// =>     "age": 14,
// =>     "nested": {
// =>         "mother": null
// =>     }
// => })

example: json validation

let mut json = JsonVerifier::new();

for character in r#"{ "name": "annie", "value": 1 }"#.bytes() {
    println!(
        "{} - {:?} - {:?}",
        character as char,
        json.update(character),
        json.status());
}

//     { - Ok(()) - Continue
//       - Ok(()) - Continue
//     " - Ok(()) - Continue
//     n - Ok(()) - Continue
//     a - Ok(()) - Continue
//     m - Ok(()) - Continue
//     e - Ok(()) - Continue
//     " - Ok(()) - Continue
//     : - Ok(()) - Continue
//       - Ok(()) - Continue
//     " - Ok(()) - Continue
//     a - Ok(()) - Continue
//     n - Ok(()) - Continue
//     n - Ok(()) - Continue
//     i - Ok(()) - Continue
//     e - Ok(()) - Continue
//     " - Ok(()) - Continue
//     , - Ok(()) - Continue
//       - Ok(()) - Continue
//     " - Ok(()) - Continue
//     v - Ok(()) - Continue
//     a - Ok(()) - Continue
//     l - Ok(()) - Continue
//     u - Ok(()) - Continue
//     e - Ok(()) - Continue
//     " - Ok(()) - Continue
//     : - Ok(()) - Continue
//       - Ok(()) - Continue
//     1 - Ok(()) - Continue
//       - Ok(()) - Continue
//     } - Ok(()) - Valid

No runtime deps