nlohmann::basic_json::array_t¶
using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
-The type used to store JSON arrays.
RFC 8259 describes JSON arrays as follows:
An array is an ordered sequence of zero or more values.
To store objects in C++, a type is defined by the template parameters explained below.
Template parameters¶
ArrayType- container type to store arrays. It must be a vector-like container: the library uses
operator[],at(), andresize(), and requires random-access iterators.std::vectorandstd::dequequalify;std::listdoes not. See Template Parameter Requirements for the full list of requirements. AllocatorType- the allocator to use for objects (e.g.,
std::allocator)
Notes¶
Default type¶
With the default values for ArrayType (std::vector) and AllocatorType (std::allocator), the default value for array_t is:
std::vector<
+The type used to store JSON arrays.
RFC 8259 describes JSON arrays as follows:
An array is an ordered sequence of zero or more values.
To store objects in C++, a type is defined by the template parameters explained below.
Template parameters¶
ArrayType- container type to store arrays. It must be a vector-like container: the library uses
operator[],at(), andresize(), and requires random-access iterators.std::vectorandstd::dequequalify;std::listdoes not. See Template Parameter Requirements for the full list of requirements. AllocatorType- the allocator to use for objects (e.g.,
std::allocator)
Notes¶
Default type¶
With the default values for ArrayType (std::vector) and AllocatorType (std::allocator), the default type for array_t is:
std::vector<
basic_json, // value_type
std::allocator<basic_json> // allocator_type
>
@@ -14,4 +14,4 @@
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
}
Output:
true
-See also¶
- object_t the type used to store JSON objects
- binary_t the type used to store binary values
- is_array checks whether the JSON value is an array
- max_size returns the maximum possible number of elements
Version history¶
- Added in version 1.0.0.
- Made
capacity()optional, so that array types such asstd::dequecan be used, in version 3.13.0 unreleased.