2 releases
| 0.2.1 | Jun 23, 2025 |
|---|---|
| 0.2.0 | Jun 17, 2025 |
#415 in Encoding
15,394 downloads per month
Used in 2 crates
(via ocidir)
50KB
936 lines
RFC 8785 Canonical JSON serialization for Rust
This crate provides a serde_json::Formatter to serialize data in canonical JSON form as defined by RFC 8785.
use canon_json::CanonicalFormatter;
use serde::Serialize;
use serde_json::json;
let value = json!({"b": 12, "a": "qwerty"});
let mut buf = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(&mut buf, CanonicalFormatter::new());
value.serialize(&mut ser).unwrap();
assert_eq!(buf, br#"{"a":"qwerty","b":12}"#);
History
This repository was originally forked from https://github.com/engineerd/cjson as it is unmaintained. But it ended up being redesigned to use the "formatter" approach that is used by olpc-cjson.
Dependencies
~0.7–1.6MB
~34K SLoC