JsonValue

Enum JsonValue 

Source
pub enum JsonValue {
    Null,
    String(String),
    Number(Number),
    Boolean(bool),
    Object(Object),
    Array(Vec<JsonValue>),
}

Variants§

§

Null

§

String(String)

§

Number(Number)

§

Boolean(bool)

§

Object(Object)

§

Array(Vec<JsonValue>)

Implementations§

Source§

impl JsonValue

Source

pub fn is_string(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn as_str(&self) -> Result<&str, JsonError>

Source

pub fn as_number(&self) -> Result<Number, JsonError>

Source

pub fn as_f64(&self) -> Result<f64, JsonError>

Source

pub fn as_f32(&self) -> Result<f32, JsonError>

Source

pub fn as_u64(&self) -> Result<u64, JsonError>

Source

pub fn as_u32(&self) -> Result<u32, JsonError>

Source

pub fn as_u16(&self) -> Result<u16, JsonError>

Source

pub fn as_u8(&self) -> Result<u8, JsonError>

Source

pub fn as_usize(&self) -> Result<usize, JsonError>

Source

pub fn as_i64(&self) -> Result<i64, JsonError>

Source

pub fn as_i32(&self) -> Result<i32, JsonError>

Source

pub fn as_i16(&self) -> Result<i16, JsonError>

Source

pub fn as_i8(&self) -> Result<i8, JsonError>

Source

pub fn as_isize(&self) -> Result<isize, JsonError>

Source

pub fn as_bool(&self) -> Result<bool, JsonError>

Source§

impl JsonValue

Source

pub fn to_struct<T: JsonExt>(self) -> Result<T, JsonError>

Source§

impl JsonValue

Source

pub fn new_object() -> JsonValue

Source

pub fn new_array() -> JsonValue

Source

pub fn push<T>(&mut self, value: T)
where T: Into<JsonValue>,

Source

pub fn len(&self) -> usize

Source

pub fn insert<T>(&mut self, key: &str, value: T) -> Result<(), JsonError>
where T: Into<JsonValue>,

Source

pub fn pretty(&self) -> String

Source

pub fn dump(&self) -> String

Source

pub fn has_key(&self, key: &str) -> bool

Source

pub fn members(&self) -> Iter<'_, JsonValue>

Source

pub fn members_mut(&mut self) -> IterMut<'_, JsonValue>

Source

pub fn into_members(self) -> IntoIter<JsonValue>

Source

pub fn entries(&self) -> ObjectIter<'_>

Source

pub fn entries_mut(&mut self) -> ObjectIterMut<'_>

Source

pub fn into_entries(self) -> ObjectIntoIter

Source

pub fn clear(&mut self)

Source

pub fn remove(&mut self, key: &str) -> JsonValue

Source

pub fn array_remove(&mut self, index: usize) -> JsonValue

Source

pub fn as_struct<T: for<'a> Deserialize<'a>>(&self) -> Result<T, JsonError>

must update_first

Source

pub fn write_file(&self, fp: impl AsRef<Path>) -> Result<(), JsonError>

Source

pub fn update_by(&mut self, other: JsonValue) -> Result<(), JsonError>

Source

pub fn set_value_by_xpath<T: Into<JsonValue>>( &mut self, xpath: &str, other: T, ) -> Result<(), JsonError>

Source

pub fn xpath(&self, xpath: &str) -> Result<&JsonValue, JsonError>

Source

pub fn remove_value_by_xpath( &mut self, xpath: &str, ) -> Result<JsonValue, JsonError>

Source

pub fn into_key(self, key: impl AsRef<str>) -> JsonValue

Source

pub fn into_index(self, index: usize) -> JsonValue

Trait Implementations§

Source§

impl Clone for JsonValue

Source§

fn clone(&self) -> JsonValue

Returns a duplicate 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<'de> Deserialize<'de> for JsonValue

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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<'a, T> From<&'a [T]> for JsonValue
where T: Into<JsonValue> + Clone,

Source§

fn from(value: &'a [T]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a String> for JsonValue

Source§

fn from(value: &'a String) -> 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<'a> From<&'a str> for JsonValue

Source§

fn from(value: &'a str) -> 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<'a, T> From<HashMap<&'a str, T>> for JsonValue
where T: Into<JsonValue>,

Source§

fn from(value: HashMap<&'a str, T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<HashMap<String, T>> for JsonValue
where T: Into<JsonValue>,

Source§

fn from(value: HashMap<String, T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Option<T>> for JsonValue
where T: Into<JsonValue>,

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<T> From<Vec<T>> for JsonValue
where T: Into<JsonValue>,

Source§

fn from(value: Vec<T>) -> 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<'a> Index<&'a String> for JsonValue

Source§

type Output = JsonValue

The returned type after indexing.
Source§

fn index(&self, index: &String) -> &JsonValue

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

impl<'a> Index<&'a str> for JsonValue

Source§

type Output = JsonValue

The returned type after indexing.
Source§

fn index(&self, index: &str) -> &JsonValue

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

impl Index<String> for JsonValue

Source§

type Output = JsonValue

The returned type after indexing.
Source§

fn index(&self, index: String) -> &JsonValue

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

impl Index<usize> for JsonValue

Source§

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<'a> IndexMut<&'a String> for JsonValue

Source§

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

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

impl<'a> IndexMut<&'a str> for JsonValue

Source§

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

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

impl IndexMut<String> for JsonValue

Source§

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

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 Into<Box<dyn Error>> for JsonValue

Source§

fn into(self) -> Box<dyn Error>

Converts this type into the (usually inferred) input type.
Source§

impl Serialize for JsonValue

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Value> for JsonValue

Source§

type Error = Error

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

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

Performs the conversion.
Source§

impl Send for JsonValue

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,