json-tools 0.1.0
JSON made easy: serialize, pretty print, read and write files, look values up by path, merge documents
Install
cargo add json-tools --registry rupm
In Ruststudio: Packages, search for json-tools, Install.
Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-22.
Versions
- 0.1.0 2026-11-22
README
# json-tools
JSON made easy: serialize, pretty print, read and write files, look values up by path, merge documents
Add it with `rupm add json-tools` (or `cargo add json-tools --registry rupm`).
```rust
use json_tools::{get, json, read_file, to_pretty, write_file, Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
#[serde(crate = "json_tools::serde")]
struct Settings { name: String, port: u16 }
fn main() -> Result<(), json_tools::Error> {
let s = Settings { name: "demo".into(), port: 8080 };
println!("{}", to_pretty(&s)?);
write_file("settings.json", &s)?;
let back: Settings = read_file("settings.json")?;
println!("{back:?}");
let doc = json!({ "user": { "tags": ["a", "b"] } });
println!("{:?}", get(&doc, "user.tags[1]")); // Some("b")
Ok(())
}
```