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_jsonaccepts those types as keys by serializing them as strings. - The same key cannot be serialized twice in an object.
serde_jsonuses the last value that is serialized for the same key.