JsonValue

Enum JsonValue 

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

Variants§

§

Null

§

Bool(bool)

§

Number(Number)

§

String(String)

§

Array(Vec<JsonValue>)

§

Object(IndexMap<String, JsonValue>)

Implementations§

Source§

impl JsonValue

Source

pub const fn is_null(&self) -> bool

Source

pub const fn is_bool(&self) -> bool

Source

pub const fn is_number(&self) -> bool

Source

pub const fn is_string(&self) -> bool

Source

pub const fn is_array(&self) -> bool

Source

pub const fn is_object(&self) -> bool

Source

pub fn is_i64(&self) -> bool

Returns true if the value is a number that can be represented as i64

Source

pub fn is_u64(&self) -> bool

Returns true if the value is a number that can be represented as u64

Source

pub fn is_f64(&self) -> bool

Source

pub fn as_bool(&self) -> Option<bool>

If the value is a Bool, returns the associated bool. Returns None otherwise.

Source

pub fn as_i64(&self) -> Option<i64>

If the value is a number, represent it as i64 if possible. Returns None otherwise.

Source

pub fn as_u64(&self) -> Option<u64>

If the value is a number, represent it as u64 if possible. Returns None otherwise.

Source

pub fn as_f64(&self) -> Option<f64>

If the value is a number, represent it as f64 if possible. Returns None otherwise.

Source

pub fn as_str(&self) -> Option<&str>

Source

pub fn as_array(&self) -> Option<&Vec<JsonValue>>

Source

pub fn as_array_mut(&mut self) -> Option<&mut Vec<JsonValue>>

Source

pub fn as_object(&self) -> Option<&IndexMap<String, JsonValue>>

Source

pub fn as_object_mut(&mut self) -> Option<&mut IndexMap<String, JsonValue>>

Source

pub fn take(&mut self) -> JsonValue

Takes the value, leaving Null in its place.

Source

pub fn type_name(&self) -> &'static str

Trait Implementations§

Source§

impl Clone for JsonValue

Source§

fn clone(&self) -> JsonValue

Returns a duplicate of the value. Read more
1.0.0§

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 Default for JsonValue

Source§

fn default() -> JsonValue

Returns the “default value” for a type. 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<&JsonValue> for Value

Source§

fn from(value: &JsonValue) -> Self

Converts to this type from the input type.
Source§

impl From<&Value> for JsonValue

Source§

fn from(value: &Value) -> Self

Converts to this type from the input type.
Source§

impl From<JsonValue> for Value

Source§

fn from(value: JsonValue) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for JsonValue

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl Index<&str> for JsonValue

Source§

type Output = JsonValue

The returned type after indexing.
Source§

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

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, key: String) -> &Self::Output

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 IndexMut<&str> for JsonValue

Source§

fn index_mut(&mut self, key: &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, key: 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 IntoJsonValue for &JsonValue

Source§

impl IntoJsonValue for JsonValue

Source§

impl PartialEq for JsonValue

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for JsonValue

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
§

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

§

fn to_string(&self) -> String

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

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.