ToJSON

Trait ToJSON 

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToJSON for &str

Source§

impl ToJSON for IpAddr

Source§

impl ToJSON for IpNet

Source§

impl ToJSON for Value

Source§

impl ToJSON for bool

Source§

impl ToJSON for char

Source§

impl ToJSON for f32

Source§

impl ToJSON for f64

Source§

impl ToJSON for i8

Source§

impl ToJSON for i16

Source§

impl ToJSON for i32

Source§

impl ToJSON for i64

Source§

impl ToJSON for u8

Source§

impl ToJSON for u16

Source§

impl ToJSON for u32

Source§

impl ToJSON for u64

Source§

impl ToJSON for usize

Source§

impl ToJSON for String

Source§

impl ToJSON for Ipv4Addr

Source§

impl ToJSON for Ipv6Addr

Source§

impl ToJSON for NonZero<i8>

Source§

impl ToJSON for NonZero<i16>

Source§

impl ToJSON for NonZero<i32>

Source§

impl ToJSON for NonZero<i64>

Source§

impl ToJSON for NonZero<u8>

Source§

impl ToJSON for NonZero<u16>

Source§

impl ToJSON for NonZero<u32>

Source§

impl ToJSON for NonZero<u64>

Source§

impl ToJSON for NonZero<usize>

Source§

impl ToJSON for Duration

Available on crate feature humantime only.
Source§

impl ToJSON for ObjectId

Available on crate feature bson only.
Source§

impl ToJSON for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

impl ToJSON for DateTime<Local>

Available on crate feature chrono only.
Source§

impl ToJSON for DateTime<Utc>

Available on crate feature chrono only.
Source§

impl ToJSON for NaiveDate

Available on crate feature chrono only.
Source§

impl ToJSON for NaiveDateTime

Available on crate feature chrono only.
Source§

impl ToJSON for NaiveTime

Available on crate feature chrono only.
Source§

impl ToJSON for LineString

Available on crate feature geo only.
Source§

impl ToJSON for MultiLineString

Available on crate feature geo only.
Source§

impl ToJSON for MultiPoint

Available on crate feature geo only.
Source§

impl ToJSON for MultiPolygon

Available on crate feature geo only.
Source§

impl ToJSON for Point

Available on crate feature geo only.
Source§

impl ToJSON for Polygon

Available on crate feature geo only.
Source§

impl ToJSON for Uri

Source§

impl ToJSON for Duration

Available on crate feature humantime only.
Source§

impl ToJSON for Ipv4Net

Source§

impl ToJSON for Ipv6Net

Source§

impl ToJSON for Struct

Available on crate feature prost-wkt-types only.
Source§

impl ToJSON for Value

Available on crate feature prost-wkt-types only.
Source§

impl ToJSON for Duration

Available on crate feature prost-wkt-types only.
Source§

impl ToJSON for Timestamp

Available on crate feature prost-wkt-types only.
Source§

impl ToJSON for Regex

Source§

impl ToJSON for Decimal

Available on crate feature rust_decimal only.
Source§

impl ToJSON for Date

Available on crate feature time only.
Source§

impl ToJSON for OffsetDateTime

Available on crate feature time only.
Source§

impl ToJSON for PrimitiveDateTime

Available on crate feature time only.
Source§

impl ToJSON for Time

Available on crate feature time only.
Source§

impl ToJSON for Url

Available on crate feature url only.
Source§

impl ToJSON for Uuid

Available on crate feature uuid only.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: ToJSON> ToJSON for &T

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: ToJSON> ToJSON for Json<T>

Available on crate feature sqlx only.
Source§

impl<T: ToJSON, R: Send + Sync> ToJSON for HashSet<T, R>

Source§

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

Implementors§