simdjson  3.11.0
Ridiculously Fast JSON
Object iteration

Methods to iterate and find object fields. More...

Functions

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::start_object () noexcept
 Start an object iteration. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::start_root_object () noexcept
 Start an object iteration from the root. More...
 
simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::check_root_object () noexcept
 Checks whether an object could be started from the root. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::started_object () noexcept
 Start an object iteration after the user has already checked and moved past the {. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::started_root_object () noexcept
 Start an object iteration from the root, after the user has already checked and moved past the {. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::has_next_field () noexcept
 Moves to the next field in an object. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< raw_json_stringsimdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::field_key () noexcept
 Get the current field's key.
 
simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::field_value () noexcept
 Pass the : in the field and move to its value.
 
simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field (const std::string_view key) noexcept
 Find the next field with the given key. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field_raw (const std::string_view key) noexcept
 Find the next field with the given key, without unescaping. More...
 
simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field_unordered_raw (const std::string_view key) noexcept
 Find the field with the given key without regard to order, and without unescaping. More...
 

Detailed Description

Methods to iterate and find object fields.

These methods generally assume the value is actually an object; the caller is responsible for keeping track of that fact.

Function Documentation

◆ check_root_object()

simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::check_root_object ( )
noexcept

Checks whether an object could be started from the root.

May be called by start_root_object.

Returns
SUCCESS if it is possible to safely start an object from the root (document level). @error INCORRECT_TYPE if there is no opening { @error TAPE_ERROR if there is no matching } at end of document

Definition at line 50 of file value_iterator-inl.h.

◆ find_field()

simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field ( const std::string_view  key)
noexcept

Find the next field with the given key.

Assumes you have called next_field() or otherwise matched the previous value.

This means the iterator must be sitting at the next key:

{ "a": 1, "b": 2 }
^

Key is raw JSON, meaning it will be matched against the verbatim JSON without attempting to unescape it. This works well for typical ASCII and UTF-8 keys (almost all of them), but may fail to match some keys with escapes (\u,
, etc.).

◆ find_field_raw()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field_raw ( const std::string_view  key)
noexcept

Find the next field with the given key, without unescaping.

This assumes object order: it will not find the field if it was already passed when looking for some other field.

Assumes you have called next_field() or otherwise matched the previous value.

This means the iterator must be sitting at the next key:

{ "a": 1, "b": 2 }
^

Key is raw JSON, meaning it will be matched against the verbatim JSON without attempting to unescape it. This works well for typical ASCII and UTF-8 keys (almost all of them), but may fail to match some keys with escapes (\u,
, etc.).

Definition at line 112 of file value_iterator-inl.h.

◆ find_field_unordered_raw()

SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::find_field_unordered_raw ( const std::string_view  key)
noexcept

Find the field with the given key without regard to order, and without unescaping.

This is an unordered object lookup: if the field is not found initially, it will cycle around and scan from the beginning.

Assumes you have called next_field() or otherwise matched the previous value.

This means the iterator must be sitting at the next key:

{ "a": 1, "b": 2 }
^

Key is raw JSON, meaning it will be matched against the verbatim JSON without attempting to unescape it. This works well for typical ASCII and UTF-8 keys (almost all of them), but may fail to match some keys with escapes (\u,
, etc.).

When find_field_unordered_raw is called, we can either be pointing at the first key, pointing outside (at the closing brace) or if a key was matched we can be either pointing right afterthe ':' right before the value (that we need skip), or we may have consumed the value and we might be at a comma or at the final brace (ready for a call to has_next_field()).

Definition at line 209 of file value_iterator-inl.h.

◆ has_next_field()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::has_next_field ( )
noexcept

Moves to the next field in an object.

Looks for , and }. If } is found, the object is finished and the iterator advances past it. Otherwise, it advances to the next value.

Returns
whether there is another field in the object. @error TAPE_ERROR If there is a comma missing between fields. @error TAPE_ERROR If there is a comma, but not enough tokens remaining to have a key, :, and value.

Definition at line 95 of file value_iterator-inl.h.

◆ start_object()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::start_object ( )
noexcept

Start an object iteration.

Returns
Whether the object had any fields (returns false for empty). @error INCORRECT_TYPE if there is no opening {

Definition at line 26 of file value_iterator-inl.h.

◆ start_root_object()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::start_root_object ( )
noexcept

Start an object iteration from the root.

Returns
Whether the object had any fields (returns false for empty). @error INCORRECT_TYPE if there is no opening { @error TAPE_ERROR if there is no matching } at end of document

Definition at line 31 of file value_iterator-inl.h.

◆ started_object()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::started_object ( )
noexcept

Start an object iteration after the user has already checked and moved past the {.

Does not move the iterator unless the object is empty ({}).

Returns
Whether the object had any fields (returns false for empty). @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the parent array or object is incomplete).

Definition at line 36 of file value_iterator-inl.h.

◆ started_root_object()

simdjson_warn_unused simdjson_inline simdjson_result< bool > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::value_iterator::started_root_object ( )
noexcept

Start an object iteration from the root, after the user has already checked and moved past the {.

Does not move the iterator unless the object is empty ({}).

Returns
Whether the object had any fields (returns false for empty). @error INCOMPLETE_ARRAY_OR_OBJECT If there are no more tokens (implying the parent array or object is incomplete).

Definition at line 80 of file value_iterator-inl.h.