![]() |
simdjson 4.0.7
Ridiculously Fast JSON
|
JSON object. More...
#include <object.h>
Classes | |
class | iterator |
Public Member Functions | |
simdjson_inline | object () noexcept |
Create a new, invalid object. | |
iterator | begin () const noexcept |
Return the first key/value pair. | |
iterator | end () const noexcept |
One past the last key/value pair. | |
size_t | size () const noexcept |
Get the size of the object (number of keys). | |
simdjson_result< element > | operator[] (std::string_view key) const noexcept |
Get the value associated with the given key. | |
simdjson_result< element > | operator[] (const char *key) const noexcept |
Get the value associated with the given key. | |
simdjson_result< element > | operator[] (int) const noexcept=delete |
simdjson_result< element > | at_pointer (std::string_view json_pointer) const noexcept |
Get the value associated with the given JSON pointer. | |
void | process_json_path_of_child_elements (std::vector< element >::iterator ¤t, std::vector< element >::iterator &end, const std::string_view &path_suffix, std::vector< element > &accumulator) const noexcept |
Recursive function which processes the JSON path of each child element. | |
simdjson_result< std::vector< element > > | at_path_with_wildcard (std::string_view json_path) const noexcept |
Adds support for JSONPath expression with wildcards '*'. | |
simdjson_result< element > | at_path (std::string_view json_path) const noexcept |
Get the value associated with the given JSONPath expression. | |
simdjson_result< element > | at_key (std::string_view key) const noexcept |
Get the value associated with the given key. | |
std::vector< element > & | get_values (std::vector< element > &out) const noexcept |
Gets the values associated with keys of an object This function has linear-time complexity: the keys are checked one by one. | |
simdjson_result< element > | at_key_case_insensitive (std::string_view key) const noexcept |
Get the value associated with the given key in a case-insensitive manner. | |
operator element () const noexcept | |
Implicitly convert object to element. | |
|
noexcept |
Create a new, invalid object.
Definition at line 83 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given key.
The key will be matched against unescaped JSON:
dom::parser parser; int64_t(parser.parse(R"({ "a
": 1 })"_padded)["a\n"]) == 1 parser.parse(R"({ "a
": 1 })"_padded)["a\\n"].get_uint64().error() == NO_SUCH_FIELD
This function has linear-time complexity: the keys are checked one by one.
Definition at line 246 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given key in a case-insensitive manner.
It is only guaranteed to work over ASCII inputs.
Note: The key will be matched against unescaped JSON.
This function has linear-time complexity: the keys are checked one by one.
Definition at line 270 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given JSONPath expression.
We only support JSONPath queries that trivially convertible to JSON Pointer queries: key names and array indices.
https://www.rfc-editor.org/rfc/rfc9535 (RFC 9535)
Definition at line 149 of file object-inl.h.
|
inlinenoexcept |
Adds support for JSONPath expression with wildcards '*'.
Definition at line 175 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given JSON pointer.
We use the RFC 6901 https://tools.ietf.org/html/rfc6901 standard, interpreting the current node as the root of its own JSON document.
dom::parser parser; object obj = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})"_padded); obj.at_pointer("/foo/a/1") == 20 obj.at_pointer("/foo")["a"].at(1) == 20
It is allowed for a key to be the empty string:
dom::parser parser; object obj = parser.parse(R"({ "": { "a": [ 10, 20, 30 ] }})"_padded); obj.at_pointer("//a/1") == 20 obj.at_pointer("/")["a"].at(1) == 20
Definition at line 104 of file object-inl.h.
|
inlinenoexcept |
Return the first key/value pair.
Part of the std::iterable interface.
Definition at line 85 of file object-inl.h.
|
inlinenoexcept |
One past the last key/value pair.
Part of the std::iterable interface.
Definition at line 89 of file object-inl.h.
|
inlinenoexcept |
Gets the values associated with keys of an object This function has linear-time complexity: the keys are checked one by one.
Definition at line 256 of file object-inl.h.
|
inlinenoexcept |
Implicitly convert object to element.
Definition at line 280 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given key.
The key will be matched against unescaped JSON:
dom::parser parser; int64_t(parser.parse(R"({ "a
": 1 })"_padded)["a\n"]) == 1 parser.parse(R"({ "a
": 1 })"_padded)["a\\n"].get_uint64().error() == NO_SUCH_FIELD
This function has linear-time complexity: the keys are checked one by one.
Definition at line 101 of file object-inl.h.
|
inlinenoexcept |
Get the value associated with the given key.
The key will be matched against unescaped JSON:
dom::parser parser; int64_t(parser.parse(R"({ "a
": 1 })"_padded)["a\n"]) == 1 parser.parse(R"({ "a
": 1 })"_padded)["a\\n"].get_uint64().error() == NO_SUCH_FIELD
This function has linear-time complexity: the keys are checked one by one.
Definition at line 98 of file object-inl.h.
|
inlinenoexcept |
Recursive function which processes the JSON path of each child element.
Definition at line 155 of file object-inl.h.
|
inlinenoexcept |
Get the size of the object (number of keys).
It is a saturated value with a maximum of 0xFFFFFF: if the value is 0xFFFFFF then the size is 0xFFFFFF or greater.
Definition at line 93 of file object-inl.h.