JSON Serialization with eXtra Small memory footprint.
Provides helper to produce JSON for existing, JSON-agnostic data model.
This library is not yet published to crates.io as it is still very immature.
Add following dependency to your Cargo.toml
:
toml
[dependencies]
jsonxs = { git = "https://github.com/pkozelka/jsonxs-rs", branch = "master" }
In your code, use it like this:
```rust use std::collections::HashMap; use std::io::Result;
use jsonxs::{JsonXsSerializer, JsonXsValue};
pub fn jsonsave(map: &HashMap
json.open_obj("map")?;
for (k, v) in map {
json.element(k, v)?;
}
json.close()?;
json.close()?; // closes root object, "}"
json.done() // checks that nesting went well
}
fn main() { let mut map = HashMap::new(); map.insert("hello".tostring(), "world".tostring()); map.insert("how".tostring(), "are you".tostring());
json_save(&map).unwrap();
} ```