nlohmann::basic_json::max_size - renxiaobo27/json GitHub Wiki
size_type max_size() const;Returns the type-dependent maximum number of elements the JSON container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container.
The return value depends on the different value types and is defined as follows:
| Value type | return value |
|---|---|
| null | 0 |
| boolean | 1 |
| string | 1 |
| number | 1 |
| object | ObjectType::max_size() |
| array | ArrayType::max_size() |
None.
Constant, as long as ArrayType and ObjectType satisfy the Container concept.
None. The function's noexcept-specification is noexcept.
This value is typically equal to std::numeric_limits<size_type>::max(), and reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.
#include <iostream>
#include <json.hpp>
int main()
{
nlohmann::json array {"string", true, 17, 23.42};
std::cout << "Maximum size of a JSON array is " << array.max_size() << "\n";
}Output:
Maximum size of a JSON array is 1152921504606846975
-
size
returns the number of elements