[][src]Struct json_in_type::object::ToJSONObject

pub struct ToJSONObject<K, V, I>(pub I)
where
    K: JSONString,
    V: JSONValue,
    &'a I: IntoIterator<Item = &'a (K, V)>
;

A struct used to wrap another type and make it serializable as a json object. The other type has to be able to yield (key, value) pairs by implementing IntoIterator.

Examples

Serialize a vec as a json object

use json_in_type::object::ToJSONObject;
use json_in_type::JSONValue;

let my_obj = ToJSONObject(vec![("x", 1), ("y", 2)]);

assert_eq!("{\"x\":1,\"y\":2}", my_obj.to_json_string());

Trait Implementations

impl<K, V, I> JSONValue for ToJSONObject<K, V, I> where
    K: JSONString,
    V: JSONValue,
    &'a I: IntoIterator<Item = &'a (K, V)>, 
[src]

fn to_json_string(&self) -> String[src]

Returns the object formatted as a json string Read more

fn to_json_buffer(&self) -> Vec<u8>[src]

Returns a buffer containing the bytes of a json representation of the object

Auto Trait Implementations

impl<K, V, I> Send for ToJSONObject<K, V, I> where
    I: Send

impl<K, V, I> Sync for ToJSONObject<K, V, I> where
    I: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]