Skip to main content

codec_jcs/
lib.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! JSON Canonicalization Scheme helpers.
6//!
7//! Object member ordering and finite floating-point formatting follow RFC
8//! 8785. Integer values represented exactly by `serde_json` as `i64`/`u64`
9//! are emitted verbatim, including values outside the ES6 safe-integer range;
10//! callers that require strict I-JSON interoperability should reject those
11//! integers before canonicalization.
12
13mod canonicalize;
14mod error;
15
16pub use canonicalize::canonicalize_json;
17pub use error::JcsError;
18
19/// Maximum array/object nesting depth accepted by [`canonicalize_json`].
20///
21/// Defense in depth: `serde_json`'s parser already caps nesting, but a
22/// caller may hand in a `Value` built by other means, so canonicalization
23/// enforces its own bound rather than trusting the input's provenance.
24pub const MAX_NESTING_DEPTH: usize = 128;