Crate smoljson

Crate smoljson 

Source
Expand description

This is a minimalist JSON library that trades away several desirable qualities (ergonomics, performance, …) in favor of small code size and fast compiles.

It doesn’t support serde, or any other custom derive. I’m not particularly happy with the API, and will likely change it to be better in the future. As a result, docs are somewhat sparse.

§Basic Usage

use smoljson::Value;
let v = Value::from_str(r#"{"foo": [1, 2, {"bar": 3}]}"#).unwrap();
let expected = smoljson::json!({"foo": [1, 2, {"bar": 3}]});
assert_eq!(v, expected);

§Intended use case

The intended use case is situtions where small number of low maintenance (rare changes to struct layout) data structures need (de)serialization in a project where keeping a low compile time is important.

§JSON with Comments (CJSON) support

By default, strictly correct JSON is required, and this does not allow comments. However this crate supports “JSON with Comments”, aka cjson. This is a non-standard extension to JSON that allows JavaScript-style comments. It’s somewhat common now, and is supported by things like VSCode (and as described by the jsonc-parser NPM package).

This is generally enabled on a per-use case using the Dialect, but the default settings can be controlled using some cargo features. See Dialect::DEFAULT’s documentation for details.

Re-exports§

pub use read::Dialect;
pub use read::Error;
pub use read::Reader;
pub use value::Value;

Modules§

read
value
write

Macros§

json

Type Aliases§

ValOwn