1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! # `json-canon`
//!
//! Serialize JSON into a canonical format.
//!
//! Safe for generating a consistent cryptographic hash or signature across platforms.
//!
//! Follows [RFC8785: JSON Canonicalization Scheme (JCS)]
//!
//! [RFC8785: JSON Canonicalization Scheme (JCS)]: https://tools.ietf.org/html/rfc8785
//!
//! ## Example
//!
//! ```rust
//! # use json_canon::to_string;
//! # use serde_json::{json, Error};
//! # fn main() -> Result<(), Error> {
//! let data = json!({
//!     "from_account": "543 232 625-3",
//!     "to_account": "321 567 636-4",
//!     "amount": 500,
//!     "currency": "USD"
//! });
//!
//! println!("{}", to_string(&data)?);
//! // {"amount":500,"currency":"USD","from_account":"543 232 625-3","to_account":"321 567 636-4"}
//! # Ok(())
//! # }
//! ```
//!
//! ## Caveats
//!
//! `serde_json` deserializes `f64::NAN` and `f64::Infinite` as `None`, so if given a Rust struct with these values, the `json-canon` will currently output `"null"`.
//!

mod object;
mod ser;

pub use self::ser::{to_string, to_vec, to_writer};