1# basic_json
2
3!!! note
4
5    This page is under construction.
6
7Defined in header `<json.hpp>`
8
9```cpp
10template<template<typename, typename, typename...> class ObjectType,
11         template<typename, typename...> class ArrayType,
12         class StringType, class BooleanType, class NumberIntegerType,
13         class NumberUnsignedType, class NumberFloatType,
14         template<typename> class AllocatorType,
15         template<typename, typename = void> class JSONSerializer,
16         class BinaryType>
17class basic_json
18```
19
20## Specializations
21
22- json
23- ordered_json
24
25## Template parameters
26
27- ObjectType
28- ArrayType
29- StringType
30- BooleanType
31- NumberIntegerType
32- NumberUnsignedType
33- NumberFloatType
34- AllocatorType
35- JSONSerializer
36- BinaryType
37
38## Iterator invalidation
39
40## Member types
41
42- value_t
43- json_pointer
44- json_serializer
45- error_handler_t
46- cbor_tag_handler_t
47- initializer_list_t
48- input_format_t
49- json_sax_t
50
51### Exceptions
52
53- exception
54- parse_error
55- invalid_iterator
56- type_error
57- out_of_range
58- other_error
59
60### Container types
61
62- value_type
63- reference
64- const_reference
65- difference_type
66- size_type
67- allocator_type
68- pointer
69- const_pointer
70- iterator
71- const_iterator
72- reverse_iterator
73- const_reverse_iterator
74
75### JSON value data types
76
77- object_comparator_t
78- object_t
79- array_t
80- string_t
81- boolean_t
82- number_integer_t
83- number_unsigned_t
84- number_float_t
85- binary_t
86
87### Parser callback
88
89- parse_event_t
90- parser_callback_t
91
92## Member functions
93
94- (constructor)
95- (destructor)
96- binary (static) - explicitly create a binary array
97- array (static) - explicitly create an array
98- object (static) - explicitly create an object
99- operator= - copy assignment
100
101### Object inspection
102
103Functions to inspect the type of a JSON value.
104
105- type - return the type of the JSON value
106- is_primitive - return whether type is primitive
107- is_structured - return whether type is structured
108- is_null - return whether value is null
109- is_boolean - return whether value is a boolean
110- is_number - return whether value is a number
111- is_number_integer - return whether value is an integer number
112- is_number_unsigned - return whether value is an unsigned integer number
113- is_number_float - return whether value is a floating-point number
114- is_object - return whether value is an object
115- is_array - return whether value is an array
116- is_string - return whether value is a string
117- is_binary - return whether value is a binary array
118- is_discarded - return whether value is discarded
119- operator value_t - return the type of the JSON value
120
121### Value access
122
123Direct access to the stored value of a JSON value.
124
125- get - get a value
126- get_to - get a value
127- get_ptr - get a pointer value
128- get_ref - get a reference value
129- operator ValueType - get a value
130- get_binary - get a binary value
131
132### Element access
133
134Access to the JSON value
135
136- at - access specified array element with bounds checking
137- at - access specified object element with bounds checking
138- operator[] - access specified array element
139- operator[] - access specified object element
140- value - access specified object element with default value
141- front - access the first element
142- back - access the last element
143- erase - remove elements
144
145### Lookup
146
147- find - find an element in a JSON object
148- count - returns the number of occurrences of a key in a JSON object
149- contains - check the existence of an element in a JSON object
150
151### Iterators
152
153- begin - returns an iterator to the first element
154- cbegin - returns a const iterator to the first element
155- end - returns an iterator to one past the last element
156- cend - returns a const iterator to one past the last element
157- rbegin - returns an iterator to the reverse-beginning
158- rend - returns an iterator to the reverse-end
159- crbegin - returns a const iterator to the reverse-beginning
160- crend - returns a const iterator to the reverse-end
161- items - wrapper to access iterator member functions in range-based for
162
163### Capacity
164
165- empty - checks whether the container is empty
166- size - returns the number of elements
167- max_size - returns the maximum possible number of elements
168
169### Modifiers
170
171- clear - clears the contents
172- push_back - add an object to an array
173- operator+= - add an object to an array
174- push_back - add an object to an object
175- operator+= - add an object to an object
176- emplace_back - add an object to an array
177- emplace - add an object to an object if key does not exist
178- insert - inserts element
179- update - updates a JSON object from another object, overwriting existing keys
180- swap - exchanges the values
181
182### Lexicographical comparison operators
183
184- operator== - comparison: equal
185- operator!= - comparison: not equal
186- operator< - comparison: less than
187- operator<= - comparison: less than or equal
188- operator> - comparison: greater than
189- operator>= - comparison: greater than or equal
190
191### Serialization
192
193- [**dump**](dump.md) - serialization
194- to_string - user-defined to_string function for JSON values
195
196### Deserialization
197
198- [**parse**](parse.md) - deserialize from a compatible input
199- accept - check if the input is valid JSON
200- sax_parse - generate SAX events
201
202### Convenience functions
203
204- type_name - return the type as string
205
206### JSON Pointer functions
207
208- at - access specified object element with bounds checking via JSON Pointer
209- operator[] - access specified element via JSON Pointer
210- value - access specified object element with default value via JSON Pointer
211- flatten - return flattened JSON value
212- unflatten - unflatten a previously flattened JSON value
213
214### JSON Patch functions
215
216- patch - applies a JSON patch
217- diff (static) - creates a diff as a JSON patch
218
219### JSON Merge Patch functions
220
221- merge_patch - applies a JSON Merge Patch
222
223## Static functions
224
225- [**meta**](meta.md) - returns version information on the library
226- get_allocator - returns the allocator associated with the container
227
228### Binary formats
229
230- to_cbor - create a CBOR serialization of a given JSON value
231- to_msgpack - create a MessagePack serialization of a given JSON value
232- to_ubjson - create a UBJSON serialization of a given JSON value
233- to_bson - create a BSON serialization of a given JSON value
234- from_cbor - create a JSON value from an input in CBOR format
235- from_msgpack - create a JSON value from an input in MessagePack format
236- from_ubjson - create a JSON value from an input in UBJSON format
237- from_bson - create a JSON value from an input in BSON format
238
239## Non-member functions
240
241- operator<<(std::ostream&) - serialize to stream
242- operator>>(std::istream&) - deserialize from stream
243
244## Literals
245
246- operator""_json
247- operator""_json_pointer
248
249## Helper classes
250
251- std::hash<nlohmann::json\>
252- std::less<nlohmann::value_t\>
253- std::swap<nlohmann::json\>
254