Enum adventjson::JsonObject[][src]

pub enum JsonObject {
    Array(Vec<Self>),
    Obj(Vec<(String, Self)>),
    Number(f64),
    JsonStr(String),
    Bool(bool),
    Null,
}

A json object

A full json object

Notes

In accordance to the specification a Number may not be NaN or one of the Infinity-ies, so it is Eq and Ord

Variants

Array(Vec<Self>)

An array of objects (e.g.: [1,2,3])

Obj(Vec<(String, Self)>)

Key-value pairs (e.g.: {"first": 10, "other": 15})

Number(f64)

A number (e.g.: -0.08333)

JsonStr(String)

A string (e.g.: "Test: \"")

Bool(bool)

A boolean (e.g. true)

Null

The null-value

Implementations

impl JsonObject[src]

pub fn partial_read(
    s: &[char],
    newindex: usize
) -> Result<(Self, usize), JsonError>
[src]

Reads a json object partially

Reads a JsonObject partially and returns both, it and where the next character should be read.

Errors

Returns an JsonError if the input was invalid.

pub fn read(s: &str) -> Result<Self, JsonError>[src]

Reads a json object

Reads a JsonObject or returns an error.

Errors

Returns an JsonError if the input was invalid.

#[must_use]pub fn unique(&self) -> bool[src]

Checks if all keys are unique

RFC 8259 requires all keys in objects (“{"one": 1, "twenty": 20}”) to be unique. This function checks recursively if that condition is met.

Trait Implementations

impl Clone for JsonObject[src]

impl Debug for JsonObject[src]

impl Default for JsonObject[src]

fn default() -> Self[src]

The default value is JsonObject::Null

impl Display for JsonObject[src]

impl Eq for JsonObject[src]

Save because no not-number values are allowed in json

impl Ord for JsonObject[src]

Save because no not-number values are allowed in json

impl PartialEq<JsonObject> for JsonObject[src]

impl PartialOrd<JsonObject> for JsonObject[src]

impl StructuralPartialEq for JsonObject[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.