to_canonical_value

Function to_canonical_value 

Source
pub fn to_canonical_value<T>(
    value: T,
) -> Result<CanonicalJsonValue, CanonicalJsonError>
where T: Serialize,
Expand description

Fallible conversion from any value that implements Serialize to a CanonicalJsonValue.

This behaves similarly to serde_json::to_value(), except for the following restrictions which return errors:

  • Integers must be in the range accepted by js_int::Int.
  • Floats and bytes are not serializable.
  • Booleans and integers cannot be used as keys for an object. serde_json accepts those types as keys by serializing them as strings.
  • The same key cannot be serialized twice in an object. serde_json uses the last value that is serialized for the same key.