Function serde_json::to_string

source ·
pub fn to_string<T>(value: &T) -> Result<String>where
    T: ?Sized + Serialize,
Available on crate feature std only.
Expand description

Serialize the given data structure as a String of JSON.

Errors

Serialization can fail if T’s implementation of Serialize decides to fail, or if T contains a map with non-string keys.

Examples found in repository?
src/raw.rs (line 290)
286
287
288
289
290
291
292
pub fn to_raw_value<T>(value: &T) -> Result<Box<RawValue>, Error>
where
    T: ?Sized + Serialize,
{
    let json_string = crate::to_string(value)?;
    Ok(RawValue::from_owned(json_string.into_boxed_str()))
}