pub struct ArrayBuilder {
    pub array: JsonArray,
    pub null: bool,
    pub skip: bool,
    pub root: Option<String>,
}

Fields§

§array: JsonArray§null: bool§skip: bool§root: Option<String>

Implementations§

source§

impl ArrayBuilder

Use ArrayBuilder to produce JSON arrays

source

pub fn new() -> ArrayBuilder

source

pub fn from_json(array: Value) -> Option<ArrayBuilder>

Initialize builder with initial value.

source

pub fn build<F>(builder: F) -> ArrayBuilder
where F: FnOnce(&mut ArrayBuilder),

Create new ArrayBuilder, pass it to closure as mutable ref and return.

source

pub fn push_json(&mut self, value: Value)

Push JSON value to array.

source

pub fn array<F>(&mut self, builder: F)
where F: FnOnce(&mut ArrayBuilder),

Create new array and push it.

source

pub fn object<F>(&mut self, builder: F)
where F: FnOnce(&mut ObjectBuilder),

Create new object and push it

source

pub fn null(&mut self)

It you call null, this array will be converted to null when converting to raw JSON value.

source

pub fn skip(&mut self)

It you call skip, this array will be skipped.

source

pub fn root(&mut self, root: &str)

source

pub fn has_root(&mut self) -> bool

source

pub fn unwrap(self) -> Value

Move out internal JSON value.

source§

impl ArrayBuilder

source

pub fn push<T: Serialize>(&mut self, value: T)

Push to array something that can be converted to JSON.

source§

impl ArrayBuilder

source

pub fn objects<A, T: Iterator<Item = A>, F>(&mut self, iter: T, func: F)
where F: Fn(A, &mut ObjectBuilder),

Fill this array by objects builded from iterator.

source

pub fn arrays<A, T: Iterator<Item = A>, F>(&mut self, iter: T, func: F)
where F: Fn(A, &mut ArrayBuilder),

source

pub fn map<A, T: Iterator<Item = A>, F>(&mut self, iter: T, func: F)
where F: Fn(A) -> Value,

Fill this array by JSON values builded from iterator.

Trait Implementations§

source§

impl Serialize for ArrayBuilder

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Copy self to new JSON instance.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.