simdjson 4.6.4
Ridiculously Fast JSON
Loading...
Searching...
No Matches
simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field Class Reference

A JSON field (key/value pair) in an object. More...

#include <field.h>

Inheritance diagram for simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field:

Public Member Functions

simdjson_inline field () noexcept
 Create a new invalid field.
 
simdjson_inline simdjson_warn_unused simdjson_result< std::string_view > unescaped_key (bool allow_replacement=false) noexcept
 Get the key as a string_view (for higher speed, consider raw_key).
 
template<typename string_type >
simdjson_inline simdjson_warn_unused error_code unescaped_key (string_type &receiver, bool allow_replacement=false) noexcept
 Get the key as a string_view (for higher speed, consider raw_key).
 
simdjson_inline raw_json_string key () const noexcept
 Get the key as a raw_json_string.
 
simdjson_inline std::string_view key_raw_json_token () const noexcept
 Get the unprocessed key as a string_view.
 
simdjson_inline std::string_view escaped_key () const noexcept
 Get the key as a string_view.
 
simdjson_inline ondemand::value & value () &noexcept
 Get the field value.
 
simdjson_inline ondemand::value value () &&noexcept
 

Protected Member Functions

simdjson_inline field (raw_json_string key, ondemand::value &&value) noexcept
 

Static Protected Member Functions

static simdjson_inline simdjson_result< fieldstart (value_iterator &parent_iter) noexcept
 
static simdjson_inline simdjson_result< fieldstart (const value_iterator &parent_iter, raw_json_string key) noexcept
 

Detailed Description

A JSON field (key/value pair) in an object.

Returned from object iteration.

Extends from std::pair<raw_json_string, value> so you can use C++ algorithms that rely on pairs.

Definition at line 22 of file field.h.

Constructor & Destructor Documentation

◆ field() [1/2]

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::field ( )
noexcept

Create a new invalid field.

Exists so you can declare a variable and later assign to it before use.

Definition at line 16 of file field-inl.h.

◆ field() [2/2]

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::field ( raw_json_string  key,
ondemand::value &&  value 
)
protectednoexcept

Definition at line 18 of file field-inl.h.

Member Function Documentation

◆ escaped_key()

simdjson_inline std::string_view simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::escaped_key ( ) const
noexcept

Get the key as a string_view.

This does not include the quotes and the string is unprocessed key so it may contain escape characters (e.g., \uXXXX or
). It does not count as a consumption of the content: you can safely call it repeatedly. Use unescaped_key() to get the unescaped key.

Definition at line 60 of file field-inl.h.

◆ key()

simdjson_inline raw_json_string simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::key ( ) const
noexcept

Get the key as a raw_json_string.

Can be used for direct comparison with an unescaped C string: e.g., key() == "test". This does not count as consumption of the content: you can safely call it repeatedly. See escaped_key() for a similar function which returns a more convenient std::string_view result.

Definition at line 49 of file field-inl.h.

◆ key_raw_json_token()

simdjson_inline std::string_view simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::key_raw_json_token ( ) const
noexcept

Get the unprocessed key as a string_view.

This includes the quotes and may include some spaces after the last quote. This does not count as consumption of the content: you can safely call it repeatedly. See escaped_key().

Definition at line 55 of file field-inl.h.

◆ start() [1/2]

simdjson_inline simdjson_result< field > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::start ( const value_iterator &  parent_iter,
raw_json_string  key 
)
staticprotectednoexcept

Definition at line 30 of file field-inl.h.

◆ start() [2/2]

simdjson_inline simdjson_result< field > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::start ( value_iterator &  parent_iter)
staticprotectednoexcept

Definition at line 23 of file field-inl.h.

◆ unescaped_key() [1/2]

simdjson_inline simdjson_warn_unused simdjson_result< std::string_view > simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::unescaped_key ( bool  allow_replacement = false)
noexcept

Get the key as a string_view (for higher speed, consider raw_key).

We deliberately use a more cumbersome name (unescaped_key) to force users to think twice about using it.

This consumes the key: once you have called unescaped_key(), you cannot call it again nor can you call key().

Definition at line 34 of file field-inl.h.

◆ unescaped_key() [2/2]

template<typename string_type >
simdjson_inline simdjson_warn_unused error_code simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::unescaped_key ( string_type &  receiver,
bool  allow_replacement = false 
)
noexcept

Get the key as a string_view (for higher speed, consider raw_key).

We deliberately use a more cumbersome name (unescaped_key) to force users to think twice about using it. The content is stored in the receiver.

This consumes the key: once you have called unescaped_key(), you cannot call it again nor can you call key().

Definition at line 42 of file field-inl.h.

◆ value() [1/2]

simdjson_inline value simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::value ( ) &&
noexcept

Definition at line 71 of file field-inl.h.

◆ value() [2/2]

simdjson_inline value & simdjson::SIMDJSON_IMPLEMENTATION::ondemand::field::value ( ) &
noexcept

Get the field value.

Definition at line 67 of file field-inl.h.


The documentation for this class was generated from the following files: