pub trait JsonValue: Sized {
type ValueType<'dom>
where Self: 'dom;
Show 20 methods
// Required methods
fn get_type(&self) -> JsonType;
fn as_number(&self) -> Option<Number>;
fn as_str(&self) -> Option<&str>;
fn as_bool(&self) -> Option<bool>;
fn get<I: Index>(&self, index: I) -> Option<Self::ValueType<'_>>;
fn pointer(&self, path: &JsonPointer<'_>) -> Option<Self::ValueType<'_>>;
// Provided methods
fn is_boolean(&self) -> bool { ... }
fn is_true(&self) -> bool { ... }
fn is_false(&self) -> bool { ... }
fn is_null(&self) -> bool { ... }
fn is_number(&self) -> bool { ... }
fn is_str(&self) -> bool { ... }
fn is_array(&self) -> bool { ... }
fn is_object(&self) -> bool { ... }
fn is_f64(&self) -> bool { ... }
fn is_i64(&self) -> bool { ... }
fn is_u64(&self) -> bool { ... }
fn as_i64(&self) -> Option<i64> { ... }
fn as_u64(&self) -> Option<u64> { ... }
fn as_f64(&self) -> Option<f64> { ... }
}Expand description
A trait for all JSON values. Used by Value and LazyValue.
Required Associated Types§
Required Methods§
sourcefn as_number(&self) -> Option<Number>
fn as_number(&self) -> Option<Number>
Returns the Number value of the JsonValue if it is a Number.
sourcefn get<I: Index>(&self, index: I) -> Option<Self::ValueType<'_>>
fn get<I: Index>(&self, index: I) -> Option<Self::ValueType<'_>>
Returns the value from index if the JsonValue is an array or object
The index may be usize or &str. The usize is for array, the &str is for object.
sourcefn pointer(&self, path: &JsonPointer<'_>) -> Option<Self::ValueType<'_>>
fn pointer(&self, path: &JsonPointer<'_>) -> Option<Self::ValueType<'_>>
Returns the value from pointer path if the JsonValue is an array or object
Provided Methods§
sourcefn is_boolean(&self) -> bool
fn is_boolean(&self) -> bool
Returns true if the JsonValue is a bool.
Object Safety§
This trait is not object safe.