1 # <small>nlohmann::basic_json::</small>max_size
4 size_type max_size() const noexcept;
7 Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations,
8 i.e. `std::distance(begin(), end())` for the JSON value.
12 The return value depends on the different types and is defined as follows:
14 | Value type | return value |
15 |------------|-------------------------------------------|
16 | null | `0` (same as [`size()`](size.md)) |
17 | boolean | `1` (same as [`size()`](size.md)) |
18 | string | `1` (same as [`size()`](size.md)) |
19 | number | `1` (same as [`size()`](size.md)) |
20 | binary | `1` (same as [`size()`](size.md)) |
21 | object | result of function `object_t::max_size()` |
22 | array | result of function `array_t::max_size()` |
26 No-throw guarantee: this function never throws exceptions.
30 Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the
31 [Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `max_size()` functions have
36 This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of
37 string elements the JSON value can store which is `1`.
43 The following code calls `max_size()` on the different value types. Note the output is implementation specific.
46 --8<-- "examples/max_size.cpp"
52 --8<-- "examples/max_size.output"
57 - Added in version 1.0.0.
58 - Extended to return `1` for binary types in version 3.8.0.