Enum json_rs::json::JSONValue

source ·
pub enum JSONValue {
    Bool(bool),
    Number(f64),
    String(String),
    Array(Vec<JSONValue>),
    Object(HashMap<String, JSONValue>),
    Null,
}

Variants§

§

Bool(bool)

§

Number(f64)

§

String(String)

§

Array(Vec<JSONValue>)

§

Object(HashMap<String, JSONValue>)

§

Null

Implementations§

source§

impl JSONValue

source

pub fn get(&self, key: &str) -> Result<&JSONValue>

source

pub fn get_mut(&mut self, key: &str) -> Result<&mut JSONValue>

source

pub fn obj_insert(&mut self, key: &str, value: JSONValue) -> Result<()>

source

pub fn obj_remove(&mut self, key: &str) -> Result<(String, JSONValue)>

source

pub fn try_index(&self, index: usize) -> Result<&JSONValue>

source

pub fn try_index_mut(&mut self, index: usize) -> Result<&mut JSONValue>

source

pub fn arr_push(&mut self, val: JSONValue) -> Result<()>

source

pub fn arr_pop(&mut self) -> Result<JSONValue>

source

pub fn arr_insert(&mut self, pos: usize, val: JSONValue) -> Result<()>

source

pub fn arr_remove(&mut self, pos: usize) -> Result<JSONValue>

source

pub const fn null() -> Self

Constructs a JSON null value.

Trait Implementations§

source§

impl Cast<String> for JSONValue

source§

fn cast(&self) -> Result<String>

source§

impl Cast<bool> for JSONValue

source§

fn cast(&self) -> Result<bool>

source§

impl Cast<f32> for JSONValue

source§

fn cast(&self) -> Result<f32>

source§

impl Cast<f64> for JSONValue

source§

fn cast(&self) -> Result<f64>

source§

impl Cast<i128> for JSONValue

source§

fn cast(&self) -> Result<i128>

source§

impl Cast<i16> for JSONValue

source§

fn cast(&self) -> Result<i16>

source§

impl Cast<i32> for JSONValue

source§

fn cast(&self) -> Result<i32>

source§

impl Cast<i64> for JSONValue

source§

fn cast(&self) -> Result<i64>

source§

impl Cast<i8> for JSONValue

source§

fn cast(&self) -> Result<i8>

source§

impl Cast<isize> for JSONValue

source§

fn cast(&self) -> Result<isize>

source§

impl Cast<u128> for JSONValue

source§

fn cast(&self) -> Result<u128>

source§

impl Cast<u16> for JSONValue

source§

fn cast(&self) -> Result<u16>

source§

impl Cast<u32> for JSONValue

source§

fn cast(&self) -> Result<u32>

source§

impl Cast<u64> for JSONValue

source§

fn cast(&self) -> Result<u64>

source§

impl Cast<u8> for JSONValue

source§

fn cast(&self) -> Result<u8>

source§

impl Cast<usize> for JSONValue

source§

fn cast(&self) -> Result<usize>

source§

impl Clone for JSONValue

source§

fn clone(&self) -> JSONValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for JSONValue

source§

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

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

impl Display for JSONValue

source§

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

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

impl From<()> for JSONValue

Constructs a JSON null value. Equivalent to Self::null()

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl<T> From<Option<T>> for JSONValuewhere JSONValue: From<T>,

source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
source§

impl From<String> for JSONValue

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<JSONValue, Global>> for JSONValue

source§

fn from(value: Vec<JSONValue>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for JSONValue

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for JSONValue

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for JSONValue

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i128> for JSONValue

source§

fn from(value: i128) -> Self

Converts to this type from the input type.
source§

impl From<i16> for JSONValue

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for JSONValue

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for JSONValue

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for JSONValue

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl From<isize> for JSONValue

source§

fn from(value: isize) -> Self

Converts to this type from the input type.
source§

impl From<u128> for JSONValue

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for JSONValue

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for JSONValue

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for JSONValue

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for JSONValue

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for JSONValue

source§

fn from(value: usize) -> Self

Converts to this type from the input type.
source§

impl FromStr for JSONValue

§

type Err = JSONError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Index<&str> for JSONValue

§

type Output = JSONValue

The returned type after indexing.
source§

fn index(&self, index: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<String> for JSONValue

§

type Output = JSONValue

The returned type after indexing.
source§

fn index(&self, index: String) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<usize> for JSONValue

§

type Output = JSONValue

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<&str> for JSONValue

source§

fn index_mut(&mut self, index: &str) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl IndexMut<String> for JSONValue

source§

fn index_mut(&mut self, index: String) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for JSONValue

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl PartialEq<JSONValue> for JSONValue

source§

fn eq(&self, other: &JSONValue) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialEq<T> for JSONValuewhere JSONValue: Cast<T>, T: PartialEq<T>,

source§

fn eq(&self, other: &T) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Vec<u8, Global>> for JSONValue

§

type Error = JSONError

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

fn try_from(value: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for JSONValue

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.