Rust minimalist JSON management with stdt::json

This JSON crate is built as part of a zero-dependency stdt tools library. The purpose is clear: provide just enough JSON handling to be useful, while remaining compact, dependency-free, and easy to read.

The architecture reflects the purpose. At its core there is only one data type, Value, an enum that represents the six JSON primitives: null, boolean, number, string, array, and object. Everything flows through this type. Parsing is handled by a small, recursive descent parser, which reads directly from a character stream and produces a Value. The errors are explicit and easy to match on. There is also a macro, json!, that expands to Value and makes inline JSON construction easy without external code generation.

Serialization is provided implementing Display for Value. This means that converting JSON back to text naturally goes through Rust’s standard formatting system: to_string, println!, or format! all produce valid JSON. The choice to use Display is interesting. It avoids extra surface area and keeps the interface idiomatic: if you know how to format a string in Rust, you know how to print JSON. The parser is explicit and reliable, producing predictable errors.

Using it is simple. A JSON object can be created with the macro:

let cfg = json::json!({
    "debug": true,
    "limit": 100,
    "servers": ["alpha", "beta"]
});

The value can be serialized to a string with cfg.to_string(), producing compact JSON without extra whitespace. Parsing is equally direct:

let parsed = json::from_str(r#"{"ok":true,"items":[1,2,3]}"#).unwrap();

Once parsed, you work with it by matching on Value and modifying it directly. Printing it again automatically yields valid JSON.

Because this crate lives in a micro standard library, much is intentionally missing. There is no integration with serde, no derive macros, no I/O helpers like from_reader or to_writer. There is no pretty-printing: output is always compact. Numbers are always parsed as f64 without integer or arbitrary precision handling. Objects are just hash maps without ordering guarantees. There is no query layer such as JSON Pointer, and the parser accepts only strict JSON, without comments or extensions. But . . . who needs all of this in all projects?

HERE IS THE LIBRARY ON CRATES.IO

HERE IS THE LIBRARY DOCS


You'll only receive email when they publish something new.

More from GSLF
All posts