pub enum ValueRef<'a, T: Json> {
Null,
Boolean(bool),
Number(&'a T::Number),
String(&'a T::String),
Array(&'a T::Array),
Object(&'a T::Object),
}
Expand description
JSON value reference.
Variants§
Null
Boolean(bool)
Number(&'a T::Number)
String(&'a T::String)
Array(&'a T::Array)
Object(&'a T::Object)
Implementations§
Source§impl<'a, T: Json> ValueRef<'a, T>
impl<'a, T: Json> ValueRef<'a, 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_boolean
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 as_u32(&self) -> Option<u32>
pub fn as_u32(&self) -> Option<u32>
Returns this number as an u32
if it can be exactly represented as such.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns this number as an u64
if it can be exactly represented as such.
Sourcepub fn as_i32(&self) -> Option<i32>
pub fn as_i32(&self) -> Option<i32>
Returns this number as an i32
if it can be exactly represented as such.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns this number as an i64
if it can be exactly represented as such.
Sourcepub fn as_f32(&self) -> Option<f32>
pub fn as_f32(&self) -> Option<f32>
Returns this number as an f32
if it can be exactly represented as such.
Sourcepub fn as_f32_lossy(&self) -> Option<f32>
pub fn as_f32_lossy(&self) -> Option<f32>
Returns this number as an f32
if it is a number, potentially losing precision in the process.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns this number as an f64
if it can be exactly represented as such.
Sourcepub fn as_f64_lossy(&self) -> Option<f64>
pub fn as_f64_lossy(&self) -> Option<f64>
Returns this number as an f64
if it is a number, potentially losing precision in the process.
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.
Source§impl<'a, T: Json> ValueRef<'a, T>
impl<'a, T: Json> ValueRef<'a, T>
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<&'a T::Number>
pub fn as_number(&self) -> Option<&'a T::Number>
If the value is a number, returns a reference to it.
Returns None
otherwise.
Sourcepub fn as_string(&self) -> Option<&'a T::String>
pub fn as_string(&self) -> Option<&'a T::String>
If the value is a string, 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 into_str(self) -> Option<&'a str>
pub fn into_str(self) -> Option<&'a str>
If the value is a string, returns its associated str
.
Returns None
otherwise.
Sourcepub fn as_array(&self) -> Option<&'a T::Array>
pub fn as_array(&self) -> Option<&'a T::Array>
If the value is an array, returns a reference to it.
Returns None
otherwise.