Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evanxg852000/erjson
A simple rust json parser
https://github.com/evanxg852000/erjson
json json-parser rust rust-library
Last synced: about 13 hours ago
JSON representation
A simple rust json parser
- Host: GitHub
- URL: https://github.com/evanxg852000/erjson
- Owner: evanxg852000
- License: mit
- Created: 2020-01-16T16:17:43.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T07:18:34.000Z (almost 5 years ago)
- Last Synced: 2024-08-10T10:25:45.090Z (3 months ago)
- Topics: json, json-parser, rust, rust-library
- Language: Rust
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## erjson: A simple rust json parser
# Examples
```rust
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)
}}
```