Crates.io | json-rs |
lib.rs | json-rs |
version | 0.1.1 |
source | src |
created_at | 2023-07-08 17:00:29.880581 |
updated_at | 2023-07-08 17:16:34.115259 |
description | Lightweight JSON reader and writer, written in pure rust. |
homepage | https://github.com/HilbertCurve/json-rs |
repository | https://github.com/HilbertCurve/json-rs |
max_upload_size | |
id | 911571 |
size | 71,158 |
A lightweight json parser and serializer.
This crate does not rely on any I/O actions, and purely works with &str
objects.
Example:
my_file.json
:
{
"foo": "bar",
"baz": [
2,
3.4,
false
],
"nested": {
"inner_foo": "inner_bar",
"has_answer": [
40,
41,
42,
43e1
]
}
}
main.rs
:
use std::fs;
fn main() -> json::Result<()> {
let values: JSONValue = JSONValue::from_str(fs::read("my_file.json"))?;
let bar: String = values["foo"].cast()?;
assert_eq!(values["foo"], "bar");
assert_eq!(values["baz"][2], false);
assert_eq!(values["nested"]["has_answer"][2], 42);
}