Skip to main content

canonicalize

Function canonicalize 

Source
pub fn canonicalize(value: &Value) -> Result<Vec<u8>, A2aError>
Available on crate feature signing only.
Expand description

Produces an RFC 8785 (JCS) canonical JSON serialization of a value.

JCS defines a deterministic serialization for JSON values:

  • Object keys sorted lexicographically by UTF-16 code units (RFC 8785 §3.2.3 — note this differs from Unicode code-point order for supplementary-plane characters such as emoji)
  • No insignificant whitespace
  • Numbers formatted per ECMAScript Number::toString (RFC 8785 §3.2.2)
  • Strings escaped per RFC 8785 rules

§Errors

Returns an error if the value cannot be serialized.