Function ruma::signatures::canonical_json

source ·
pub fn canonical_json(
    object: &BTreeMap<String, CanonicalJsonValue>,
) -> Result<String, Error>
Available on crate feature signatures only.
Expand description

Converts an event into the canonical string form.

§Parameters

  • object: The JSON object to convert.

§Examples

let input = r#"{
    "本": 2,
    "日": 1
}"#;

let object = serde_json::from_str(input).unwrap();
let canonical = ruma_signatures::canonical_json(&object).unwrap();

assert_eq!(canonical, r#"{"日":1,"本":2}"#);