Simple JSON parser written with Rust. Wasm / no_std ready.
```bash
no_std
env:just build
no_std
env:just test
std
env:just run ```
To parse a string into JSON object
```rust use simplejson2::{ self, parsejson, impls::SimpleError };
fn parsesimple() -> Result<(), SimpleError> { let jsonstr = r#"{"data":{"id":"bitcoin","symbol":"BTC"},"timestamp":1574224303089}"#;
// To parse a string to JSON object
let json: JsonValue = parse_json(&json_str)?;
// To get a value out from the JSON object
let json_obj = &json.get_object()?[0];
// We use vec of char because in `no_std` env, there is no `String`
assert_eq!(json_obj.0, "data".chars().collect::<Vec<char>>());
let inner_obj = &json_obj.1.get_object()?[0];
assert_eq!(inner_obj.0, "id".chars().collect::<Vec<char>>());
// If we are in `std` env, we can retrieve value back as `String`
assert_eq!(inner_obj.1.get_string()?, "bitcoin");
// -- snip
}
```
This project is derived from xlc/lite-json