1# basic_json::max_size 2 3```cpp 4size_type max_size() const noexcept; 5``` 6 7Returns the maximum number of elements a JSON value is able to hold due to system or library implementation limitations, 8i.e. `std::distance(begin(), end())` for the JSON value. 9 10## Return value 11 12The return value depends on the different types and is defined as follows: 13 14Value type | return value 15----------- | ------------- 16null | `0` (same as [`size()`](size.md)) 17boolean | `1` (same as [`size()`](size.md)) 18string | `1` (same as [`size()`](size.md)) 19number | `1` (same as [`size()`](size.md)) 20binary | `1` (same as [`size()`](size.md)) 21object | result of function `object_t::max_size()` 22array | result of function `array_t::max_size()` 23 24## Exception safety 25 26No-throw guarantee: this function never throws exceptions. 27 28## Complexity 29 30Constant, 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 32constant complexity. 33 34## Notes 35 36This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of 37string elements the JSON value can store which is `1`. 38 39## Example 40 41??? example 42 43 The following code calls `max_size()` on the different value types. Note the output is implementation specific. 44 45 ```cpp 46 --8<-- "examples/max_size.cpp" 47 ``` 48 49 Output: 50 51 ```json 52 --8<-- "examples/max_size.output" 53 ``` 54 55## Version history 56 57- Added in version 1.0.0. 58- Extended to return `1` for binary types in version 3.8.0. 59