| Home | Libraries | People | FAQ | More

#### object

A dynamically sized associative container of JSON key/value pairs.

##### Synopsis

Defined in header `<boost/json/object.hpp>`

    class object

##### Types

Name | Description
--- | ---
allocator_type | The type of Allocator returned by `get_allocator`.
const_iterator | A const random access iterator to an element.
const_pointer | A const pointer to an element.
const_reference | A const reference to an element.
const_reverse_iterator | A const reverse random access iterator to an element.
difference_type | The type used to represent signed integers.
iterator | A random access iterator to an element.
key_type | The type of keys.
mapped_type | The type of mapped values.
pointer | A pointer to an element.
reference | A reference to an element.
reverse_iterator | A reverse random access iterator to an element.
size_type | The type used to represent unsigned integers.
value_type | The element type.

##### Member Functions

Name | Description
--- | ---
at | Access the specified element, with bounds checking. —
begin | Return an iterator to the first element. — Return a const iterator to the first element.
capacity | Return the number of elements that can be held in currently allocated memory.
cbegin | Return a const iterator to the first element.
cend | Return a const iterator to the element following the last element.
clear | Erase all elements.
contains | Return `true` if the key is found.
count | Count the number of elements with a specific key.
crbegin | Return a const reverse iterator to the first element of the reversed container.
crend | Return a const reverse iterator to the element following the last element of the reversed container.
emplace | Construct an element in-place.
empty | Return whether there are no elements.
end | Return an iterator to the element following the last element. — Return a const iterator to the element following the last element.
erase | Erase an element.
find | Find an element with a specific key.
get_allocator | Return the associated `memory_resource`.
if_contains | Return a pointer to the value if the key is found, or null.
insert | Insert elements.
insert_or_assign | Insert an element or assign to the current element if the key already exists.
object [constructor] | Default constructor. — Constructor. — Move constructor. — Pilfer constructor. — Copy constructor. — Construct from initializer-list.
operator= | Copy assignment. — Move assignment. — Assignment.
operator[] | Access or insert the specified element.
rbegin | Return a reverse iterator to the first element of the reversed container. — Return a const reverse iterator to the first element of the reversed container.
rend | Return a reverse iterator to the element following the last element of the reversed container. — Return a const reverse iterator to the element following the last element of the reversed container.
reserve | Increase the capacity to at least a certain amount.
size | Return the number of elements.
stable_erase | Erase an element preserving order.
storage | Return the associated `memory_resource`.
swap | Swap two objects.
~object [destructor] | Destructor.

##### Static Member Functions

Name | Description
--- | ---
max_size | Return the maximum number of elements any object can hold.

##### Friends

Name | Description
--- | ---
operator== | Return `true` if two objects are equal.
operator!= | Return `true` if two objects are not equal.
operator<< | Serialize `object` to an output stream.
swap | Swap two objects.

##### Description

This is an associative container whose elements are key/value pairs with unique keys.

The elements are stored contiguously; iterators are ordinary pointers, allowing random access pointer arithmetic for retrieving elements. In addition, the container maintains an internal index to speed up find operations, reducing the average complexity for most lookups and insertions.

Reallocations are usually costly operations in terms of performance, as elements are copied and the internal index must be rebuilt. The `reserve` function can be used to eliminate reallocations if the number of elements is known beforehand.

##### Allocators

All elements stored in the container, and their children if any, will use the same memory resource that was used to construct the container.

##### Thread Safety

Non-const member functions may not be called concurrently with any other member functions.

##### Satisfies

ContiguousContainer, ReversibleContainer, and SequenceContainer.

Convenience header `<boost/json.hpp>`