Skip to main content

Module json

Module json 

Source
Expand description

Serialization helpers for raw and canonical JSON values.

The conversion functions bridge Serde values to Ruma’s raw and canonical representations. A generic deserializer adapts string-backed fields to types implementing FromStr, and a lenient one reads a boolean that may arrive spelled as a string.

Re-exportsΒ§

use std::borrow::Cow; πŸ”’
use std::fmt; πŸ”’
use std::io; πŸ”’
use std::marker::PhantomData; πŸ”’
use std::str::FromStr; πŸ”’
use ruma::CanonicalJsonError; πŸ”’
use ruma::CanonicalJsonObject; πŸ”’
use ruma::canonical_json::try_from_json_map; πŸ”’
use ruma::serde::Raw; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserializer; πŸ”’
use serde::de::IgnoredAny; πŸ”’
use crate::Result; πŸ”’

StructsΒ§

Counter πŸ”’
An io::Write sink that counts bytes without buffering them.

EnumsΒ§

LenientBool πŸ”’
A boolean as a loosely typed source may spell it.

FunctionsΒ§

deserialize_from_str
Deserializes a string and parses it through FromStr.
deserialize_lenient_bool
Deserializes an optional boolean that may arrive spelled as a string.
serialized_len
Measures the length of a value’s JSON serialization.
to_canonical_object
Converts a serializable value into a canonical JSON object.
to_raw
Serializes a value into Ruma’s raw JSON representation.