JsonArray

Struct JsonArray 

Source
pub struct JsonArray { /* private fields */ }

Implementations§

Source§

impl JsonArray

Source

pub fn empty() -> JsonArray

Creates an empty JSON array. This is useful for building a JSON array from scratch.

Source

pub fn from_string(json: &str) -> JsonArray

Builds a JSONArray from a string containing children that implement JsonRetreive

§Arguments
  • json — An owned string containing the JSON.
Source

pub fn get<T: JsonRetrieve>(&self, index: usize) -> Result<T, JsonParseError>

Gets the object at the index as a type that implements JsonRetrieve.

§Arguments
  • index — The index to retrieve from.
Source

pub fn map<T: JsonRetrieve>(&self) -> Result<Vec<T>, JsonParseError>

Converts all elements of this JSONArray to a type that implements JsonRetrieve. Progagates errors if any child keys are invalid.

Source

pub fn map_drop<T: JsonRetrieve>(&self) -> Vec<T>

Converts all elements of this JSONArray to a type that implements JsonRetrieve. Silently drops any invalid children.

Trait Implementations§

Source§

impl Debug for JsonArray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JsonArray

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ToJson for JsonArray

Source§

fn to_json(&self) -> String

ToJson creates a JSON string from anything which implements it

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>,

Source§

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>,

Source§

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.