pub struct ToJSONObject<K, V, I>(pub I)
where
K: JSONString,
V: JSONValue,
for<'a> &'a I: IntoIterator<Item = &'a (K, V)>;
Expand description
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());
Tuple Fields§
§0: I
Trait Implementations§
Auto Trait Implementations§
impl<K, V, I> Freeze for ToJSONObject<K, V, I>where
I: Freeze,
impl<K, V, I> RefUnwindSafe for ToJSONObject<K, V, I>where
I: RefUnwindSafe,
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,
impl<K, V, I> Unpin for ToJSONObject<K, V, I>where
I: Unpin,
impl<K, V, I> UnwindSafe for ToJSONObject<K, V, I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more