Small JSON Parser in no_std
This library reads and parses JSON strings.
Its intended use case is to read a JSON payload once
It does not serialise data.
Sample usage
Simply put this in your Cargo.toml:
[]
= { = "https://github.com/rspencer01/microjson" }
You can read strings and integers easily:
use JSONValue;
let integer = parse
.expect;
let value = integer.read_integer;
let string = parse
.expect;
let value = integer.read_string;
You can read arrays like this:
use JSONValue;
let input = r#" [0, 1, 2, 3, 4, 5] "#;
let array = parse
.expect;
for in array.iter_array.unwrap.enumerate
And, of course, any combination of the above:
use JSONValue;
let input = r#" { "arr": [3, "foo", 3.625, false] } "#;
let object = parse
.expect;
assert_eq!;
If you are unsure what kind of data you have, you can query the [JSONValueType].
use ;
let input = r#" 3.1415 "#;
let object = parse
.expect;
match object.value_type