pub enum Value {
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Assoc(Assoc),
Array(Array),
Tuple(Vec<Value>),
Variant(Variant),
}
Expand description
Representation of a Yojson value.
Variants§
Null
JSON null
Bool(bool)
JSON boolean
Integer(i64)
JSON number without decimal point or exponent.
Float(f64)
JSON number, Infinity, -Infinity or NaN.
String(String)
JSON string.
Assoc(Assoc)
JSON object.
Array(Array)
JSON array
Tuple(Vec<Value>)
Tuple (non-standard extension of JSON). Syntax: ("abc", 123)
.
Variant(Variant)
Variant (non-standard extension of JSON). Syntax: <"Foo">
or <"Bar":123>
.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Extracts the integer value if it is an integer.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Tests whether this value is an integer.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
Extracts the array value if it is an array.
Sourcepub fn as_tuple_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_tuple_mut(&mut self) -> Option<&mut Vec<Value>>
Extracts the list values if it is a tuple.
Sourcepub fn as_assoc(&self) -> Option<&HashMap<String, Value>>
pub fn as_assoc(&self) -> Option<&HashMap<String, Value>>
Extracts the objects value if it is an assoc.
Sourcepub fn as_assoc_mut(&mut self) -> Option<&mut HashMap<String, Value>>
pub fn as_assoc_mut(&mut self) -> Option<&mut HashMap<String, Value>>
Extracts the objects value if it is an assoc.
Sourcepub fn as_variant(&self) -> Option<&Variant>
pub fn as_variant(&self) -> Option<&Variant>
Extracts the variant value if it is a variant.
Sourcepub fn as_variant_mut(&mut self) -> Option<&mut Variant>
pub fn as_variant_mut(&mut self) -> Option<&mut Variant>
Extracts the variant value if it is a variant.
Sourcepub fn is_variant(&self) -> bool
pub fn is_variant(&self) -> bool
Tests whether this value is a variant.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin 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