Trait serializers::ToJson [−][src]
pub trait ToJson<'a, T: 'a> { fn to_value(&self, value: &T) -> Value; fn serialize(&self, value: &T) -> String { ... } fn serialize_iter<I>(&self, values: I) -> String
where
I: IntoIterator<Item = &'a T>, { ... } }
The trait responsible for actually compiling the JSON.
You shouldn't have to implement this trait manually. It will be automatically implemented for
anything that implements Serializer
.
Required Methods
Provided Methods
fn serialize(&self, value: &T) -> String
Turn the given object into JSON.
fn serialize_iter<I>(&self, values: I) -> String where
I: IntoIterator<Item = &'a T>,
I: IntoIterator<Item = &'a T>,
Turn the given iterable into JSON array. The main usecase for this is to turn Vec
s into
JSON arrays.
Implementors
impl<'a, T: 'a, K> ToJson<'a, T> for K where
K: Serializer<T>,