Skip to main content

Json

Enum Json 

Source
pub enum Json {
    Null,
    Bool(bool),
    Number(Decimal),
    String(String),
    Array(Vec<Json>),
    Object(Vec<(String, Json)>),
}
Expand description

A JSON value.

An object keeps its members in the order they were read or built; the canonical writer sorts them. A tree built here never holds two members with one key.

Variants§

§

Null

null.

§

Bool(bool)

true or false.

§

Number(Decimal)

A number, exactly.

§

String(String)

A string.

§

Array(Vec<Json>)

An array.

§

Object(Vec<(String, Json)>)

An object.

Implementations§

Source§

impl Json

Source

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

What kind of JSON value this is, for a message: "a string".

Source

pub fn canonical(&self) -> String

The canonical text of this value (abi.md, The canonical form).

Source

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

The member key of an object, if this is an object that has one.

Trait Implementations§

Source§

impl Clone for Json

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Json

Source§

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

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

impl Drop for Json

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Json

Source§

impl Nested for Json

A value nests as deeply as the type its schema is written for, so it is a Nested tree, which drops on a native stack of bounded size.

Source§

fn parts(&self) -> impl DoubleEndedIterator<Item = &Json>

An array’s items, or an object’s members’ values.

Source§

const LEAF: Json = Json::Null

A node with no parts, left in a part’s place when it is moved out.
Source§

fn parts_mut(&mut self) -> impl Iterator<Item = &mut Json>

The parts only self holds, in Nested::parts order, for moving out: none of those it shares with another tree.
Source§

fn fold<F>(&self, fold: &mut F) -> <F as Fold<Self>>::Made
where F: Fold<Self>,

What fold makes of self, built bottom-up. Read more
Source§

fn same_tree( &self, other: &Self, same_node: impl FnMut(&Self, &Self) -> bool, ) -> bool

Whether self and other are alike node by node, by same_node, which says whether two nodes are alike on their own, with as many parts: with each node’s count of parts, pre-order spells the tree.
Source§

fn free_parts(&mut self)

Frees each part only self holds that has parts of its own, leaving Nested::LEAF in its place: what dropping self does first, so a tree nested however deep drops on a native stack of fixed size.
Source§

impl PartialEq for Json

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Json

Auto Trait Implementations§

§

impl Forget for Json

§

impl Freeze for Json

§

impl Move for Json

§

impl RefUnwindSafe for Json

§

impl Send for Json
where RawVecInner: Send,

§

impl Sync for Json
where RawVecInner: Sync,

§

impl Unpin for Json
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Json

§

impl UnwindSafe for Json
where RawVecInner: UnwindSafe,

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

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.