53 lines
1.7 KiB
Plaintext
53 lines
1.7 KiB
Plaintext
[/
|
|
Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
Official repository: https://github.com/cppalliance/json
|
|
]
|
|
|
|
[/-----------------------------------------------------------------------------]
|
|
|
|
[section array]
|
|
|
|
A __value__ stores an instance of __array__ as the underlying representation
|
|
for a JSON array. Instances of the __array__ type function identically to
|
|
a __std_vector__ of __value__. Additionally:
|
|
|
|
* All values inserted into the container will use the same __storage_ptr__
|
|
as the container itself.
|
|
|
|
An empty array may be constructed without incurring any memory allocations
|
|
using the default memory resource. A __storage_ptr__ can also be explicitly specified:
|
|
|
|
[snippet_arrays_1]
|
|
|
|
Initializer lists can be used to construct objects with initial
|
|
contents. These constructors may allocate memory and throw:
|
|
|
|
[snippet_arrays_2]
|
|
|
|
Alternatively, elements may be inserted after construction:
|
|
|
|
[snippet_arrays_3]
|
|
|
|
Similar to its standard library counterpart, elements may be accessed directly
|
|
by their 0-based index with bounds checking using
|
|
[link json.ref.boost__json__array.at.overload1 `at`],
|
|
or without bounds checking using
|
|
[link json.ref.boost__json__array.operator_lb__rb_ `operator[]`]:
|
|
|
|
[snippet_arrays_4]
|
|
|
|
For the complete listing of all available member functions and nested
|
|
types, see the reference page for __array__.
|
|
|
|
[heading Formatted Output]
|
|
|
|
When an __array__ is formatted to a __std_ostream__, the result is a valid
|
|
JSON. That is, the array will be output with square brackets and the comma
|
|
separated list of values, as per the JSON specification.
|
|
|
|
[endsect]
|