pub trait ToJSON: Type {
    // Required method
    fn to_json(&self) -> Option<Value>;

    // Provided method
    fn to_json_string(&self) -> String { ... }
}
Expand description

Represents a type that can converted to JSON value.

Required Methods§

source

fn to_json(&self) -> Option<Value>

Convert this value to Value.

Provided Methods§

source

fn to_json_string(&self) -> String

Convert this value to JSON string.

Implementations on Foreign Types§

source§

impl ToJSON for Value

source§

impl<T: ToJSON, const LEN: usize> ToJSON for [T; LEN]

source§

impl ToJSON for NaiveTime

source§

impl ToJSON for u16

source§

impl ToJSON for f64

source§

impl ToJSON for Decimal

source§

impl ToJSON for NaiveDateTime

source§

impl ToJSON for bool

source§

impl ToJSON for DateTime<FixedOffset>

source§

impl<K, V> ToJSON for HashMap<K, V>where K: ToString + FromStr + Eq + Hash + Sync + Send, V: ToJSON,

source§

impl ToJSON for ObjectId

source§

impl ToJSON for u64

source§

impl ToJSON for DateTime<Utc>

source§

impl ToJSON for usize

source§

impl<T: ToJSON> ToJSON for HashSet<T>

source§

impl ToJSON for Ipv6Net

source§

impl ToJSON for Ipv6Addr

source§

impl<T: ToJSON> ToJSON for &[T]

source§

impl ToJSON for OffsetDateTime

source§

impl<T: ToJSON> ToJSON for Arc<T>

source§

impl<K, V> ToJSON for BTreeMap<K, V>where K: ToString + FromStr + Ord + Sync + Send, V: ToJSON,

source§

impl ToJSON for Url

source§

impl ToJSON for u32

source§

impl ToJSON for Regex

source§

impl ToJSON for i64

source§

impl ToJSON for i8

source§

impl ToJSON for Uuid

source§

impl<T: ToJSON> ToJSON for Option<T>

source§

impl ToJSON for Duration

source§

impl ToJSON for i16

source§

impl<'a> ToJSON for &'a str

source§

impl ToJSON for DateTime<Local>

source§

impl ToJSON for IpNet

source§

impl ToJSON for f32

source§

impl ToJSON for Ipv4Net

source§

impl<T: ToJSON> ToJSON for Vec<T>

source§

impl ToJSON for char

source§

impl ToJSON for i32

source§

impl ToJSON for IpAddr

source§

impl<T: ToJSON> ToJSON for BTreeSet<T>

source§

impl ToJSON for Time

source§

impl ToJSON for Uri

source§

impl ToJSON for PrimitiveDateTime

source§

impl<T: ToJSON> ToJSON for &T

source§

impl ToJSON for String

source§

impl ToJSON for Date

source§

impl ToJSON for NaiveDate

source§

impl ToJSON for Ipv4Addr

source§

impl ToJSON for u8

source§

impl<T: ToJSON> ToJSON for Box<T>

Implementors§