simdjson  0.3.1
Ridiculously Fast JSON
Classes | Public Member Functions | List of all members
simdjson::dom::object Class Reference

JSON object. More...

Inheritance diagram for simdjson::dom::object:

Classes

class  iterator
 

Public Member Functions

really_inline object () noexcept
 Create a new, invalid object.
 
iterator begin () const noexcept
 Return the first key/value pair. More...
 
iterator end () const noexcept
 One past the last key/value pair. More...
 
simdjson_result< element > operator[] (const std::string_view &key) const noexcept
 Get the value associated with the given key. More...
 
simdjson_result< element > operator[] (const char *key) const noexcept
 Get the value associated with the given key. More...
 
simdjson_result< element > at (const std::string_view &json_pointer) const noexcept
 Get the value associated with the given JSON pointer. More...
 
simdjson_result< element > at_key (const std::string_view &key) const noexcept
 Get the value associated with the given key. More...
 
simdjson_result< element > at_key_case_insensitive (const std::string_view &key) const noexcept
 Get the value associated with the given key in a case-insensitive manner. More...
 

Detailed Description

JSON object.

Definition at line 182 of file document.h.

Member Function Documentation

◆ at()

simdjson_result< element > simdjson::dom::object::at ( const std::string_view &  json_pointer) const
inlinenoexcept

Get the value associated with the given JSON pointer.

dom::parser parser; object obj = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})"); obj.at("foo/a/1") == 20 obj.at("foo")["a"].at(1) == 20

Returns
The value associated with the given JSON pointer, or:
  • NO_SUCH_FIELD if a field does not exist in an object
  • INDEX_OUT_OF_BOUNDS if an array index is larger than an array length
  • INCORRECT_TYPE if a non-integer is used to access an array
  • INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed

Definition at line 616 of file document.h.

◆ at_key()

simdjson_result< element > simdjson::dom::object::at_key ( const std::string_view &  key) const
inlinenoexcept

Get the value associated with the given key.

The key will be matched against unescaped JSON:

dom::parser parser; parser.parse(R"({ "a
": 1 })")["a\n"].get<uint64_t>().value == 1 parser.parse(R"({ "a
": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD

Returns
The value associated with this field, or:
  • NO_SUCH_FIELD if the field does not exist in the object

Definition at line 653 of file document.h.

◆ at_key_case_insensitive()

simdjson_result< element > simdjson::dom::object::at_key_case_insensitive ( const std::string_view &  key) const
inlinenoexcept

Get the value associated with the given key in a case-insensitive manner.

Note: The key will be matched against unescaped JSON.

Returns
The value associated with this field, or:
  • NO_SUCH_FIELD if the field does not exist in the object

Definition at line 665 of file document.h.

◆ begin()

object::iterator simdjson::dom::object::begin ( ) const
inlinenoexcept

Return the first key/value pair.

Part of the std::iterable interface.

Definition at line 603 of file document.h.

◆ end()

object::iterator simdjson::dom::object::end ( ) const
inlinenoexcept

One past the last key/value pair.

Part of the std::iterable interface.

Definition at line 606 of file document.h.

◆ operator[]() [1/2]

simdjson_result< element > simdjson::dom::object::operator[] ( const char *  key) const
inlinenoexcept

Get the value associated with the given key.

The key will be matched against unescaped JSON:

dom::parser parser; parser.parse(R"({ "a
": 1 })")["a\n"].get<uint64_t>().value == 1 parser.parse(R"({ "a
": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD

Returns
The value associated with this field, or:
  • NO_SUCH_FIELD if the field does not exist in the object
  • INCORRECT_TYPE if this is not an object

Definition at line 613 of file document.h.

◆ operator[]() [2/2]

simdjson_result< element > simdjson::dom::object::operator[] ( const std::string_view &  key) const
inlinenoexcept

Get the value associated with the given key.

The key will be matched against unescaped JSON:

dom::parser parser; parser.parse(R"({ "a
": 1 })")["a\n"].get<uint64_t>().value == 1 parser.parse(R"({ "a
": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD

Returns
The value associated with this field, or:
  • NO_SUCH_FIELD if the field does not exist in the object
  • INCORRECT_TYPE if this is not an object

Definition at line 610 of file document.h.


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