Skip to main content

JsonValueNode

Enum JsonValueNode 

Source
pub enum JsonValueNode {
    Object(JsonObject),
    Array(JsonArray),
    String(JsonString),
    Number(JsonNumber),
    Boolean(JsonBoolean),
    Null(JsonNull),
}
Expand description

Represents any valid JSON value.

Variants§

§

Object(JsonObject)

A JSON object (collection of key-value pairs).

§

Array(JsonArray)

A JSON array (ordered list of values).

§

String(JsonString)

A JSON string.

§

Number(JsonNumber)

A JSON number (represented as f64).

§

Boolean(JsonBoolean)

A JSON boolean (true or false).

§

Null(JsonNull)

A JSON null value.

Implementations§

Source§

impl JsonValueNode

Source

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

Returns the value as a string slice, if it is a string.

Source

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

Returns the value as an f64, if it is a number.

Source

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

Returns the value as a bool, if it is a boolean.

Source

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

Returns the value as a u64, if it is a number.

Source

pub fn as_array(&self) -> Option<&JsonArray>

Returns the value as a reference to a JsonArray, if it is an array.

Source

pub fn as_object(&self) -> Option<&JsonObject>

Returns the value as a reference to a JsonObject, if it is an object.

Source

pub fn get(&self, key: &str) -> Option<&JsonValueNode>

Gets a value from the object by key, if this value is an object.

Source

pub fn to_string(&self) -> String

Converts the JSON value to its string representation.

Trait Implementations§

Source§

impl AsDocument for JsonValueNode

Source§

fn as_document(&self, params: &Self::Params) -> Doc<'_>

Converts this type to a document for pretty printing. Read more
Source§

type Params = ()

The type of parameters used for formatting. Defaults to () if not specified.
Source§

impl Clone for JsonValueNode

Source§

fn clone(&self) -> JsonValueNode

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 JsonValueNode

Source§

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

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

impl<'de> Deserialize<'de> for JsonValueNode

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 JsonValueNode

Source§

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

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

impl From<&str> for JsonValueNode

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for JsonValueNode

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, JsonValueNode>> for JsonValueNode

Source§

fn from(fields: HashMap<String, JsonValueNode>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<JsonValueNode>> From<Option<T>> for JsonValueNode

Source§

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

Converts to this type from the input type.
Source§

impl From<String> for JsonValueNode

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<JsonValueNode>> for JsonValueNode

Source§

fn from(elements: Vec<JsonValueNode>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for JsonValueNode

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for JsonValueNode

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for JsonValueNode

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for JsonValueNode

Source§

fn from(i: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for JsonValueNode

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for JsonValueNode

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for JsonValueNode

Source§

fn from(u: u64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for JsonValueNode

Source§

fn from(u: usize) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<JsonValueNode>> FromIterator<T> for JsonValueNode

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for JsonValueNode

Source§

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

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

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 Serialize for JsonValueNode

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 ToSource for JsonValueNode

Source§

fn to_source(&self, buffer: &mut SourceBuffer)

Writes the source code representation of this type to the provided buffer.
Source§

fn to_source_string(&self) -> String

Converts this type to a source code string.
Source§

impl StructuralPartialEq for JsonValueNode

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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