| Crates.io | canon-json |
| lib.rs | canon-json |
| version | 0.2.1 |
| created_at | 2025-06-17 11:22:39.679204+00 |
| updated_at | 2025-06-23 11:16:42.556828+00 |
| description | serde_json Formatter to serialize as RFC 8785 canonical JSON |
| homepage | |
| repository | https://github.com/containers/canon-json-rs |
| max_upload_size | |
| id | 1715566 |
| size | 103,436 |
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}"#);
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.