pub struct Value<'bytes, 'parent, B: BytesLike<'bytes>, S: Stack> { /* private fields */ }Expand description
A JSON value.
Implementations§
Source§impl<'bytes, 'parent, B: BytesLike<'bytes>, S: Stack> Value<'bytes, 'parent, B, S>
impl<'bytes, 'parent, B: BytesLike<'bytes>, S: Stack> Value<'bytes, 'parent, B, S>
Sourcepub fn is_object(&self) -> Result<bool, JsonError<'bytes, B, S>>
pub fn is_object(&self) -> Result<bool, JsonError<'bytes, B, S>>
Check if the current item is an object.
Sourcepub fn fields(
self,
) -> Result<FieldIterator<'bytes, 'parent, B, S>, JsonError<'bytes, B, S>>
pub fn fields( self, ) -> Result<FieldIterator<'bytes, 'parent, B, S>, JsonError<'bytes, B, S>>
Iterate over the fields within this object.
If a field is present multiple times, this will yield each instance.
Sourcepub fn is_array(&self) -> Result<bool, JsonError<'bytes, B, S>>
pub fn is_array(&self) -> Result<bool, JsonError<'bytes, B, S>>
Check if the current item is an array.
Sourcepub fn iterate(
self,
) -> Result<ArrayIterator<'bytes, 'parent, B, S>, JsonError<'bytes, B, S>>
pub fn iterate( self, ) -> Result<ArrayIterator<'bytes, 'parent, B, S>, JsonError<'bytes, B, S>>
Iterate over all items within this container.
Sourcepub fn is_str(&self) -> Result<bool, JsonError<'bytes, B, S>>
pub fn is_str(&self) -> Result<bool, JsonError<'bytes, B, S>>
Check if the current item is a string.
Sourcepub fn to_str(
self,
) -> Result<impl use<'bytes, B, S> + Iterator<Item = Result<char, JsonError<'bytes, B, S>>>, JsonError<'bytes, B, S>>
pub fn to_str( self, ) -> Result<impl use<'bytes, B, S> + Iterator<Item = Result<char, JsonError<'bytes, B, S>>>, JsonError<'bytes, B, S>>
Get the current item as a ‘string’.
As we cannot perform allocations, we do not yield a alloc::string::String but rather an
iterator for the contents of the serialized string (with its escape sequences handled). This
may be converted to an String with .collect::<Result<String, _>>()?.
RFC 8259 allows strings to specify invalid UTF-8 codepoints. This library supports working with such values, as required to be compliant with RFC 8259, but this function’s return value will error when attempting to return a non-UTF-8 value. Please keep this subtlety in mind.
Sourcepub fn as_i64(&self) -> Result<i64, JsonError<'bytes, B, S>>
pub fn as_i64(&self) -> Result<i64, JsonError<'bytes, B, S>>
Get the current item as an i64.
This uses the definition of a number defined in RFC 8259, then constrains it to having no
fractional, exponent parts. Then, it’s yielded if it’s representable within an i64.
This is exact. It does not go through f64 and does not experience its approximations.