object

## `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` | Associated 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.
`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.
`erase` | Remove an element.
`find` | Find an element with a specific key.
`get_allocator` | Return the associated allocator.
`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 an existing element.
`object` [constructor] | Constructors.
`operator=` | Assignment operators.
`operator[]` | Access or insert an element.
`rbegin` | Return a 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.
`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.
`try_at` | Access the specified element, with bounds checking.
`~object` [destructor] | Destructor.

### Static Member Functions

Name | Description
--- | ---
`max_size` | The maximum number of elements an object can hold.

### Friends

Name | Description
--- | ---
`operator!=` | Compare two objects for inequality.
`operator<<` | Serialize to an output stream.
`operator==` | Compare two objects for equality.
`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>.

Edit this page