pub enum Value {
Undefined,
Null,
Bool(bool),
Number(f64),
String(String),
Array(Vec<Value>),
Object(Object),
}Expand description
A JS value as JSON.parse returns it and JSON.stringify writes it.
Variants§
Undefined
JS undefined. JSON.parse never returns it. An object property that
holds it keeps its position in the key order and is skipped by
stringify, as JS skips it; in an array it is written as null.
Null
Bool(bool)
Number(f64)
String(String)
Array(Vec<Value>)
Object(Object)
Implementations§
Source§impl Value
impl Value
pub fn as_str(&self) -> Option<&str>
pub fn as_f64(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_array(&self) -> Option<&Vec<Value>>
pub fn as_object(&self) -> Option<&Object>
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
The property key of an object; None for anything else.
pub fn is_undefined(&self) -> bool
pub fn is_null(&self) -> bool
Trait Implementations§
Source§impl SchemaValue for Value
impl SchemaValue for Value
Source§fn to_schema_value(&self) -> Value
fn to_schema_value(&self) -> Value
The value as the schema’s JSON;
Value::Undefined when it has none.Source§fn from_schema_value(value: &Value) -> Option<Self>
fn from_schema_value(value: &Value) -> Option<Self>
The value a parsed JSON value stands for, or
None when it is not
one.impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Forget for Value
impl Freeze for Value
impl Move for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more