pub enum Value<T: Json> {
Null,
Boolean(bool),
Number(T::Number),
String(T::String),
Array(T::Array),
Object(T::Object),
}Expand description
Any JSON value.
Variants§
Null
JSON null value.
Boolean(bool)
JSON boolean value (true or false).
Number(T::Number)
JSON number, wether integer of floating point.
String(T::String)
JSON string value.
Array(T::Array)
JSON array of values.
Object(T::Object)
JSON object.
Implementations§
Source§impl<T: Json> Value<T>
impl<T: Json> Value<T>
Sourcepub fn is_bool(&self) -> bool
pub fn is_bool(&self) -> bool
Returns true if the value is a boolean. Returns false otherwise.
For any value on which is_bool returns true,
as_bool is guaranteed to return the boolean value.
Sourcepub fn is_number(&self) -> bool
pub fn is_number(&self) -> bool
Returns true if the value is a number. Returns false otherwise.
For any value on which is_number returns true,
as_number is guaranteed to return the number value.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns true if the value is a string.
Returns false otherwise.
For any value on which is_string returns true,
as_str is guaranteed to return the string value.
Sourcepub fn is_array(&self) -> bool
pub fn is_array(&self) -> bool
Returns true if the value is an array.
Returns false otherwise.
For any value on which is_array returns true,
as_array is guaranteed to return the array value.
Sourcepub fn is_object(&self) -> bool
pub fn is_object(&self) -> bool
Returns true if the value is an object.
Returns false otherwise.
For any value on which is_object returns true,
as_object is guaranteed to return the object value.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
If the value is a boolean, returns the associated bool.
Returns None otherwise.
Sourcepub fn as_number(&self) -> Option<&T::Number>
pub fn as_number(&self) -> Option<&T::Number>
If the value is a number, returns a reference to it.
Returns None otherwise.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the value is a string, returns its associated str.
Returns None otherwise.
Sourcepub fn as_array(&self) -> Option<&T::Array>
pub fn as_array(&self) -> Option<&T::Array>
If the value is an array, returns a reference to it.
Returns None otherwise.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut T::Array>
pub fn as_array_mut(&mut self) -> Option<&mut T::Array>
If the value is an array, returns a mutable reference to it.
Returns None otherwise.
Sourcepub fn as_object(&self) -> Option<&T::Object>
pub fn as_object(&self) -> Option<&T::Object>
If the value is an object, returns a reference to it.
Returns None otherwise.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut T::Object>
pub fn as_object_mut(&mut self) -> Option<&mut T::Object>
If the value is an object, returns a mutable reference to it.
Returns None otherwise.
pub fn as_value_ref(&self) -> ValueRef<'_, T>
pub fn as_value_mut(&mut self) -> ValueMut<'_, T>
Trait Implementations§
Source§impl<T: Json> Default for Value<T>
impl<T: Json> Default for Value<T>
Source§fn default() -> Self
fn default() -> Self
The default value is Value::Null.