pub struct Object { /* private fields */ }Expand description
A builder for one JSON object.
It writes the opening brace when the first field arrives, so an object
that has no field is {} and not a broken one.
Implementations§
Source§impl Object
impl Object
Sourcepub fn field<F>(&mut self, name: &str, value: F) -> &mut Object
pub fn field<F>(&mut self, name: &str, value: F) -> &mut Object
Write the name of a field and its value, which the caller writes.
The value is written by the closure into the same buffer, so a field that is an array or another object nests without a value tree in between.
Sourcepub fn text(&mut self, name: &str, value: &str) -> &mut Object
pub fn text(&mut self, name: &str, value: &str) -> &mut Object
Write a field whose value is a text.
Sourcepub fn number(&mut self, name: &str, value: i64) -> &mut Object
pub fn number(&mut self, name: &str, value: i64) -> &mut Object
Write a field whose value is a whole number.
Sourcepub fn boolean(&mut self, name: &str, value: bool) -> &mut Object
pub fn boolean(&mut self, name: &str, value: bool) -> &mut Object
Write a field whose value is a truth value.
Sourcepub fn optional_number(&mut self, name: &str, value: Option<i64>) -> &mut Object
pub fn optional_number(&mut self, name: &str, value: Option<i64>) -> &mut Object
Write a field whose value is a whole number, or null when it is not there.
Auto Trait Implementations§
impl Forget for Object
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnsafeUnpin for Object
impl UnwindSafe for Object
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