pub struct Value<'read, 'parent, R: Read<'read>, S: Stack> { /* private fields */ }Expand description
A JSON value.
Implementations§
Source§impl<'read, 'parent, R: Read<'read>, S: Stack> Value<'read, 'parent, R, S>
impl<'read, 'parent, R: Read<'read>, S: Stack> Value<'read, 'parent, R, S>
Sourcepub fn kind(&mut self) -> Result<Type, JsonError<'read, R, S>>
pub fn kind(&mut self) -> Result<Type, JsonError<'read, R, S>>
Get the type of the current item.
This does not assert it’s a valid instance of this class of items. It solely asserts if this is a valid item, it will be of this type.
Sourcepub fn fields(
self,
) -> Result<FieldIterator<'read, 'parent, R, S>, JsonError<'read, R, S>>
pub fn fields( self, ) -> Result<FieldIterator<'read, 'parent, R, S>, JsonError<'read, R, S>>
Iterate over the fields within this object.
If a field is present multiple times, this will yield each instance.
Sourcepub fn iterate(
self,
) -> Result<ArrayIterator<'read, 'parent, R, S>, JsonError<'read, R, S>>
pub fn iterate( self, ) -> Result<ArrayIterator<'read, 'parent, R, S>, JsonError<'read, R, S>>
Iterate over all items within this container.
Sourcepub fn to_str(
self,
) -> Result<impl use<'read, 'parent, R, S> + Iterator<Item = Result<char, JsonError<'read, R, S>>>, JsonError<'read, R, S>>
pub fn to_str( self, ) -> Result<impl use<'read, 'parent, R, S> + Iterator<Item = Result<char, JsonError<'read, R, S>>>, JsonError<'read, R, 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. If the underlying JSON is valid, the deserializer will remain usable afterwards however, even though the rest of the non-UTF-8 string will be inaccesible. Please keep this detail in mind.