🔥 clean up
26 files changed
-1355
No files matched your search
@@ -1,157 +0,0 @@
|
||||
Defined in header [`json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp)
|
||||
|
||||
```cpp
|
||||
template <
|
||||
class ObjectType = std::map,
|
||||
class ArrayType = std::vector,
|
||||
class StringType = std::string,
|
||||
class BooleanType = bool,
|
||||
class NumberIntegerType = int64_t,
|
||||
class NumberFloatType = double,
|
||||
class AllocatorType = std::allocator
|
||||
> class basic_json;
|
||||
```
|
||||
|
||||
## Template parameters
|
||||
|
||||
- `ObjectType` - container type used for JSON objects
|
||||
- `ArrayType` - container type used for JSON arrays
|
||||
- `StringType` - container type used for JSON strings
|
||||
- `BooleanType` - type used for JSON boolean
|
||||
- `NumberIntegerType` - type used for JSON numbers (integers)
|
||||
- `NumberFloatType` - type used for JSON numbers (floating point)
|
||||
- `AllocatorType` - [Allocator](http://en.cppreference.com/w/cpp/concept/Allocator) type used to allocate internal storage
|
||||
|
||||
## Typedefs
|
||||
|
||||
| Type | Definition |
|
||||
| --- | --- |
|
||||
| `object_t` | `ObjectType<StringType, basic_json>` |
|
||||
| `array_t` | `ArrayType<basic_json>` |
|
||||
| `string_t` | `StringType` |
|
||||
| `boolean_t` | `BooleanType` |
|
||||
| `number_integer_t` | `NumberIntegerType` |
|
||||
| `number_float_t` | `NumberFloatType` |
|
||||
| `list_init_t` | `std::initializer_list<basic_json>` |
|
||||
| `json` | `basic_json<>` |
|
||||
|
||||
Note the type `json` is a typedef for the class `basic_json` with its default types, resulting in the following typedefs:
|
||||
|
||||
| Type | Definition |
|
||||
| --- | --- |
|
||||
| `json::object_t` | `std::map<std::string, json>` |
|
||||
| `json::array_t` | `std::vector<json>` |
|
||||
| `json::string_t` | `std::string` |
|
||||
| `json::boolean_t` | `bool` |
|
||||
| `json::number_integer_t` | `int64_t` |
|
||||
| `json::number_float_t` | `double` |
|
||||
| `json::list_init_t` | `std::initializer_list<json>` |
|
||||
|
||||
## Member types
|
||||
|
||||
| Member type | Definition |
|
||||
| --- | --- |
|
||||
| `value_type` | `basic_json` |
|
||||
| `reference` | `value_type&` |
|
||||
| `const_reference` | `const value_type&` |
|
||||
| `difference_type` | `std::ptrdiff_t` |
|
||||
| `size_type` | `std::size_t` |
|
||||
| `allocator_type` | `AllocatorType<basic_json>` |
|
||||
| `pointer` | `std::allocator_traits<allocator_type>::pointer` |
|
||||
| `const_pointer` | `std::allocator_traits<allocator_type>::const_pointer` |
|
||||
| `iterator` | random access iterator |
|
||||
| `const_iterator` | constant random access iterator |
|
||||
| `reverse_iterator` | `std::reverse_iterator<iterator>` |
|
||||
| `const_reverse_iterator` | `std::reverse_iterator<const_iterator>` |
|
||||
|
||||
## Member functions
|
||||
|
||||
- [**(constructor)**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::basic_json)<br>
|
||||
constructs the container
|
||||
- [**(destructor)**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::~basic_json)<br>
|
||||
destructs the container
|
||||
- [**operator=**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::operator=)<br>
|
||||
assigns values to the container
|
||||
- [**get_allocator**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::get_allocator)<br>
|
||||
returns the associated allocator
|
||||
|
||||
### Type support
|
||||
|
||||
- [**(implicit value conversion)**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::operator-T())
|
||||
- [**get**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::get)<br>
|
||||
explicit value conversion
|
||||
- `type`
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
|
||||
### Element access
|
||||
|
||||
- [**operator[]**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::operator[])<br>
|
||||
access specific element
|
||||
- [**at**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::at)<br>
|
||||
access specific element with bound checking
|
||||
- [**front**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::front)<br>
|
||||
access the first element
|
||||
- [**back**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::back)<br>
|
||||
access the last element
|
||||
|
||||
### Iterators
|
||||
|
||||
- [**begin**, **cbegin**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::begin)<br>
|
||||
returns an iterator to the beginning
|
||||
- [**end**, **cend**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::end)<br>
|
||||
returns an iterator to the end
|
||||
- [**rbegin**, **crbegin**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::rbegin)<br>
|
||||
returns a reverse iterator to the beginning
|
||||
- [**rend**, **crend**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::rend)<br>
|
||||
returns a reverse iterator to the end
|
||||
|
||||
### Capacity
|
||||
|
||||
- [**empty**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::empty)<br>
|
||||
checks whether the container is empty
|
||||
- [**size**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::size)<br>
|
||||
returns the number of elements
|
||||
- [**max_size**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::max_size)<br>
|
||||
returns the maximum possible number of elements
|
||||
|
||||
### Modifiers
|
||||
|
||||
- [**erase**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::erase)<br>
|
||||
erases elements
|
||||
- [**clear**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::clear)<br>
|
||||
clears the contents
|
||||
- `push_back`
|
||||
- `operator+=`
|
||||
- `swap`
|
||||
|
||||
### Lookup
|
||||
|
||||
- `find`
|
||||
- `count`
|
||||
|
||||
### Serialization and deserialization
|
||||
|
||||
- `dump`
|
||||
- `parse`
|
||||
|
||||
## Non-member functions
|
||||
|
||||
- `operator==`, `operator!=`, `operator<`, `operator<=`, `operator>`, `operator>=`
|
||||
- `std::swap`
|
||||
- `std::hash`
|
||||
|
||||
### Input/output
|
||||
|
||||
- `operator<<`, `operator>>`
|
||||
- `operator"" _json`
|
||||
@@ -1,32 +0,0 @@
|
||||
```cpp
|
||||
reference at(size_type idx);
|
||||
const_reference at(size_type idx) const; // 1
|
||||
```
|
||||
```cpp
|
||||
reference at(const object_t::key_type& key)
|
||||
const_reference at(const object_t::key_type& key) const // 2
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
1. Returns a reference to the element at specified index `idx`, with bounds checking. If `idx` not within the range of the container, an exception of type `std::out_of_range` is thrown (only works for arrays).
|
||||
2. Returns a reference to the mapped value of the element with key equivalent to `key`. If no such element exists, an exception of type `std::out_of_range` is thrown (only works for objects).
|
||||
|
||||
## Parameters
|
||||
|
||||
- `idx`: index of the element to return
|
||||
- `key`: key of the element to return
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to the specified value.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant.
|
||||
2. Logarithmic in the size of the container.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. `std::runtime_error` when called on a JSON container with other type than `array`; `std::out_of_range` if `!(idx < size())`.
|
||||
2. `std::runtime_error` when called on a JSON container with other type than `object`; `std::out_of_range` if the container does not have an element with the specified key.
|
||||
@@ -1,31 +0,0 @@
|
||||
```cpp
|
||||
reference back();
|
||||
const_reference back() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns a reference to the last element in the container. Calling `back` on an empty container is undefined.
|
||||
|
||||
For a JSON container `c`, the expression `return c.back();` is equivalent to `{ auto tmp = c.end(); --tmp; return *tmp; }`.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to the last element. In cast of number, string, or boolean values, a reference to the value is returned.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
`std::out_of_range` when called on null value.
|
||||
|
||||
## See also
|
||||
|
||||
- [**front**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::front)<br>
|
||||
access the first element
|
||||
@@ -1,44 +0,0 @@
|
||||
```cpp
|
||||
basic_json();
|
||||
basic_json(std::nullptr_t); // 1
|
||||
```
|
||||
```cpp
|
||||
basic_json(const value_t t); // 2
|
||||
```
|
||||
```cpp
|
||||
basic_json(const T& value); // 3
|
||||
```
|
||||
```cpp
|
||||
basic_json(std::initializer_list<basic_json> init); // 4
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
1. Creates a null object.
|
||||
2. Creates a default-initialized container of a specified type.
|
||||
3. Creates a value-initialized container of an implicitly specified type.
|
||||
4. Creates an array or object type from an initializer list.
|
||||
|
||||
In case of item 3 and 4, the following types are valid:
|
||||
|
||||
| Value type | Type `T` | Literal |
|
||||
| ---------- | --------------------- | ---- |
|
||||
| null | `std::nullptr_t` | `nullptr` |
|
||||
| boolean | any value convertible to `BooleanType` (e.g., `bool`) | `true`, `false` |
|
||||
| string | any value convertible to `StringType` (e.g., `std::string`, `const char *`) | `"hello"` |
|
||||
| number | any value convertible to `NumberIntegerType` (e.g., `int`, `unsigned int`, `long`, `int64_t`) | `10`, `-23e-23`, `3.1415926` |
|
||||
| object | any associative container whose `key_type` is convertible to `StringType` and whose `value_type` is convertible to `basic_json` with the rules described above (e.g., `std::map<std::string, basic_json>`, `std::unordered_map<std::string, int>` | `{{"one", 1}, {"two", 2}}` |
|
||||
| array | any container whose `value_type` is convertible to `basic_json` with the rules described above (e.g., `std::vector<basic_json>`, `std::list<std::string>` | {1, false, "hello"} |
|
||||
|
||||
## Parameters
|
||||
|
||||
- `t`: type name; can be `null`, `object`, `array`, `string`, `boolean`, `number_integer`, or `number_float`.
|
||||
- `value`: can be any value whose type can be translated to a JSON container (see table above).
|
||||
- `init`: an initializer list of (a) values that can be translated to a JSON container (see table above) to create an array; (b) pairs of a string type and a value that can be translate to a JSON container (see table above) to create an object.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant.
|
||||
2. Constant.
|
||||
3. Linear in the passed value.
|
||||
4. Linear in the size of the initializer list.
|
||||
@@ -1,41 +0,0 @@
|
||||
```cpp
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
const_iterator cbegin() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns an iterator to the first value in the JSON container. If the JSON container is empty, the returned iterator will be equal to [`end()`](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::end).
|
||||
|
||||

|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Iterator to the first value. Note the return value its deferencabilty depends on the different value types:
|
||||
|
||||
| value type | deferenceable | description |
|
||||
| ---------- | ------------- | ----------- |
|
||||
| null | no | `null` has no value, always equal to [`end()`](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::end) |
|
||||
| boolean | yes | iterator to the boolean value |
|
||||
| string | yes | iterator to the string value |
|
||||
| number | yes | iterator to the number value |
|
||||
| object | only if object is not empty | iterator to the begin of the object |
|
||||
| array | only if array is not empty | iterator to the begin of the array |
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## See also
|
||||
|
||||
- [**end**, **cend**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::end)<br>
|
||||
returns an iterator to the end
|
||||
@@ -1,37 +0,0 @@
|
||||
```cpp
|
||||
void clear();
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes all elements from the container. The resulting value depends on the different value types and is defined as follows:
|
||||
|
||||
| Value type | JSON value |
|
||||
| ---------- | --------------------- |
|
||||
| null | `null` |
|
||||
| boolean | `false` |
|
||||
| string | `""` |
|
||||
| number | `0` |
|
||||
| object | `{}` |
|
||||
| array | `[]` |
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
None.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the container.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## See also
|
||||
|
||||
- [**erase**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::erase)<br>
|
||||
erases elements
|
||||
@@ -1,58 +0,0 @@
|
||||
```cpp
|
||||
bool empty() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Checks if a JSON value has no elements, i.e. whether `begin() == end()`.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
The return value depends on the different value types and is defined as follows:
|
||||
|
||||
| Value type | return value |
|
||||
| ---------- | --------------------- |
|
||||
| null | `true` |
|
||||
| boolean | `false` |
|
||||
| string | `false` |
|
||||
| number | `false` |
|
||||
| object | `ObjectType::empty()` |
|
||||
| array | `ArrayType::empty()` |
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
The following code uses empty to check if a `nlohmann::json` contains any elements:
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json numbers;
|
||||
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
|
||||
|
||||
numbers.push_back(42);
|
||||
numbers.push_back(13317);
|
||||
std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
Initially, numbers.empty(): 1
|
||||
After adding elements, numbers.empty(): 0
|
||||
```
|
||||
@@ -1,32 +0,0 @@
|
||||
```cpp
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
const_iterator cend() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns an iterator to the element following the last element of the container. This element acts as a placeholder; attempting to access it results in undefined behavior.
|
||||
|
||||

|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Iterator to the element following the last element.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## See also
|
||||
|
||||
- [**begin**, **cbegin**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::begin)<br>
|
||||
returns an iterator to the beginning
|
||||
@@ -1,64 +0,0 @@
|
||||
```cpp
|
||||
iterator erase(iterator pos);
|
||||
const_iterator erase(const_iterator pos); // 1
|
||||
```
|
||||
```cpp
|
||||
iterator erase(iterator first, iterator last);
|
||||
const_iterator erase(const_iterator first, const_iterator last); // 2
|
||||
```
|
||||
```cpp
|
||||
void erase(const size_type idx); // 3
|
||||
```
|
||||
```cpp
|
||||
size_type erase(const typename object_t::key_type& key); // 4
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes specified elements from the JSON value.
|
||||
|
||||
1. Removes the element at `pos`.
|
||||
2. Removes the elements in the range [`first`; `last`).
|
||||
3. Removes the element at index `idx` (only works for arrays).
|
||||
4. Removes the element with key `key` (only works for objects).
|
||||
|
||||
Invalidates iterators and references at or after the point of the erase, including the `end()` iterator.
|
||||
|
||||
The iterator `pos` must be valid and dereferenceable. Thus the `end()` iterator (which is valid, but is not dereferencable) cannot be used as a value for `pos`.
|
||||
|
||||
The iterator `first` does not need to be dereferenceable if `first==last`: erasing an empty range is a no-op.
|
||||
|
||||
If erase is called with valid and dereferenceable iterators for JSON values of type number, string, or boolean, the value will be changed to `null`.
|
||||
|
||||
## Parameter
|
||||
|
||||
- `pos`: iterator to the element to remove
|
||||
- `first`, `last`: range of elements to remove
|
||||
- `idx`: index of the element to remove
|
||||
- `key`: key of the element to remove
|
||||
|
||||
## Return value
|
||||
|
||||
1. Iterator following the last removed element. If the iterator pos refers to the last element, the `end()` iterator is returned.
|
||||
2. Iterator following the last removed element. If the iterator pos refers to the last element, the `end()` iterator is returned.
|
||||
3. None.
|
||||
4. Number of elements removed.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Linear in distance between `pos` and the end of the container in case of arrays; amortized constant in case of objects; constant otherwise.
|
||||
2. Linear in the distance between `first` and `last`, plus linear in the distance between `last` and end of the container in case of arrays; `log(c.size()) + std::distance(first, last)` where `c` is the instance of `ObjectType` in case of objects; constant otherwise.
|
||||
3. Linear in distance between `idx` and the end of the container.
|
||||
4. `log(c.size()) + c.count(key)` where `c` is the instance of `ObjectType`.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. `std::runtime_error` when called on null type.
|
||||
2. `std::runtime_error` when called on null type.
|
||||
3. `std::runtime_error` when called on non-array types. `std::out_of_range` when `idx >= size()`.
|
||||
4. `std::runtime_error` when called on non-object types. Any exceptions thrown by the `ObjectType::Compare` object.
|
||||
|
||||
## See also
|
||||
|
||||
- [**clear**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::clear)<br>
|
||||
clears the contents
|
||||
@@ -1,31 +0,0 @@
|
||||
```cpp
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns a reference to the first element in the container. Calling `front` on an empty container is undefined.
|
||||
|
||||
For a JSON container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to the first element. In cast of number, string, or boolean values, a reference to the value is returned.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
`std::out_of_range` when called on null value.
|
||||
|
||||
## See also
|
||||
|
||||
- [**back**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::back)<br>
|
||||
access the last element
|
||||
@@ -1,65 +0,0 @@
|
||||
```cpp
|
||||
template<typename T>
|
||||
T get() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns the value of a JSON container in a variety of types.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
The return value is the JSON container's value casted to the return value type `T`. The following type lists compatible types for the different JSON value types.
|
||||
|
||||
| value type | compatible types |
|
||||
| ---------- | --------------------- |
|
||||
| null | none |
|
||||
| boolean | `boolean_t`, `bool` |
|
||||
| string | any type convertible from `string_t` |
|
||||
| number | any [arithmetic type](http://en.cppreference.com/w/cpp/types/is_arithmetic) (that is, an integral type or a floating-point type) |
|
||||
| object | `object_t`, any associative container whose `key_type` convertible from `string_t` and whose `mapped_type ` is convertible from `basic_json` |
|
||||
| array | `array_t`, any sequence container whose `value_type` is convertible from `basic_json`; furthermore, `std::set` and `std::unordered_set` with the same constraints are allowed |
|
||||
|
||||
Note that in case of objects and arrays, all values must be compatible.
|
||||
|
||||
## Complexity
|
||||
|
||||
Amortized linear in the size of the JSON type.
|
||||
|
||||
## Exceptions
|
||||
|
||||
`std::std::logic_error` if types are not compatible.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <json.hpp>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <unordered_set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j1 = {1, 2, 3.2, 4.3, 5.4};
|
||||
auto v11 = j1.get<std::vector<float>>();
|
||||
auto v12 = j1.get<std::list<int>>();
|
||||
auto v13 = j1.get<std::unordered_set<float>>();
|
||||
|
||||
nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
auto v21 = j2.get<std::map<std::string, size_t>>();
|
||||
auto v22 = j2.get<std::multimap<std::string, double>>();
|
||||
|
||||
nlohmann::json j3 = "Hello, world";
|
||||
auto v31 = j3.get<std::string>();
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**(implicit value conversion)**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::operator-T())
|
||||
@@ -1,19 +0,0 @@
|
||||
```cpp
|
||||
static allocator_type get_allocator();
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns the allocator associated with the container.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
the associated allocator
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_array() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type array.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is array, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_array() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_array() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_array() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_array() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_array() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_array() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_boolean() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type boolean.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is boolean, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_boolean() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_boolean() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_boolean() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_boolean() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_boolean() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_boolean() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_null() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type null.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is null, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_null() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_null() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_null() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_null() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_null() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_null() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_number() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type number.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is number, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_number() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_number() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_number() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_number() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_number() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_number() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_object() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type object.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is object, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_object() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_object() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_object() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_object() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_object() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_object() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
- [**is_string**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_string)<br>
|
||||
whether value is string
|
||||
@@ -1,71 +0,0 @@
|
||||
```cpp
|
||||
bool is_string() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns whether JSON container has type string.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
`true` of value type is string, `false` otherwise.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant.
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j_null;
|
||||
nlohmann::json j_boolean = true;
|
||||
nlohmann::json j_number = 17;
|
||||
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
|
||||
nlohmann::json j_array = {1, 2, 4, 8, 16};
|
||||
nlohmann::json j_string = "Hello, world";
|
||||
|
||||
std::cout << std::boolalpha << j_null.is_string() << '\n';
|
||||
std::cout << std::boolalpha << j_boolean.is_string() << '\n';
|
||||
std::cout << std::boolalpha << j_number.is_string() << '\n';
|
||||
std::cout << std::boolalpha << j_object.is_string() << '\n';
|
||||
std::cout << std::boolalpha << j_array.is_string() << '\n';
|
||||
std::cout << std::boolalpha << j_string.is_string() << '\n';
|
||||
}
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
```
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**is_null**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_null)<br>
|
||||
whether value is null
|
||||
- [**is_boolean**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_boolean)<br>
|
||||
whether value is boolean
|
||||
- [**is_number**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_number)<br>
|
||||
whether value is number
|
||||
- [**is_object**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_object)<br>
|
||||
whether value is object
|
||||
- [**is_array**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::is_array)<br>
|
||||
whether value is array
|
||||
@@ -1,61 +0,0 @@
|
||||
```cpp
|
||||
size_type max_size() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
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.
|
||||
|
||||
## Return value
|
||||
|
||||
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()` |
|
||||
|
||||
## Parameter
|
||||
|
||||
None.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Notes
|
||||
|
||||
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.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#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
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**size**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::size)<br>
|
||||
returns the number of elements
|
||||
@@ -1,55 +0,0 @@
|
||||
```cpp
|
||||
template<typename T>
|
||||
operator T() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Implicitly converts a value of a JSON container.
|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
The return value is [`get<T>()`](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::get).
|
||||
|
||||
## Complexity
|
||||
|
||||
Amortized linear in the size of the JSON type.
|
||||
|
||||
## Exceptions
|
||||
|
||||
`std::std::logic_error` if types are not compatible.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
#include <json.hpp>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <unordered_set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json j1 = {1, 2, 3.2, 4.3, 5.4};
|
||||
std::vector<float> v11 = j1;
|
||||
std::list<int> v12 = j1;
|
||||
std::unordered_set<float> v13 = j1;
|
||||
|
||||
nlohmann::json j2 = {{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
std::map<std::string, size_t> v21 = j2;
|
||||
std::multimap<std::string, double> v22 = j2;
|
||||
|
||||
nlohmann::json j3 = "Hello, world";
|
||||
std::string v31 = j3;
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**get**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::get)<br>
|
||||
explicit value conversion
|
||||
@@ -1,30 +0,0 @@
|
||||
```cpp
|
||||
reference& operator=(basic_json other)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Replaces the contents with a copy of `other`. In case `other` is an rvalue, its value is moved.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `other`: container to copy
|
||||
|
||||
## Return value
|
||||
|
||||
`*this`
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of `other`. If `other` is an rvalue, the operation has constant complexity.
|
||||
|
||||
## Exceptions
|
||||
|
||||
The function's noexcept-specification is:
|
||||
|
||||
```cpp
|
||||
std::is_nothrow_move_constructible<value_t>::value and
|
||||
std::is_nothrow_move_assignable<value_t>::value and
|
||||
std::is_nothrow_move_constructible<json_value>::value and
|
||||
std::is_nothrow_move_assignable<json_value>::value
|
||||
```
|
||||
@@ -1,36 +0,0 @@
|
||||
```cpp
|
||||
reference operator[](size_type idx); // 1
|
||||
const_reference operator[](size_type idx) const; // 2
|
||||
```
|
||||
```cpp
|
||||
reference operator[](const object_t::key_type& key) // 3
|
||||
const_reference operator[](const object_t::key_type& key) const // 4
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
1. Returns a reference to the element at specified index `idx`. In case `idx > size()`, null values are inserted between `size()` and `idx` before (only works for arrays).
|
||||
2. Returns a reference to the element at specified index `idx`. No bounds checking is performed and no values will be inserted (only works for arrays).
|
||||
3. Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion of a null value if such key does not already exist and returns a reference to this value (only works for objects).
|
||||
4. Returns a reference to the mapped value of the element with key equivalent to `key`. No bounds checking is performed and no values will be inserted (only works for objects).
|
||||
|
||||
## Parameters
|
||||
|
||||
- `idx`: index of the element to return
|
||||
- `key`: key of the element to return
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to the specified value. In case of 1 and 3, the reference may be to a newly inserted null value.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Linear in the distance between `size()` and `idx` if `idx > size()`, constant otherwise.
|
||||
2. Constant.
|
||||
3. Logarithmic in the size of the container.
|
||||
4. Logarithmic in the size of the container.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. `std::runtime_error` when called on a JSON container with other type than `array`.
|
||||
2. `std::runtime_error` when called on a JSON container with other type than `object`.
|
||||
@@ -1,32 +0,0 @@
|
||||
```cpp
|
||||
iterator rbegin();
|
||||
const_iterator rbegin() const;
|
||||
const_iterator crbegin() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns a reverse iterator to the first element of the reversed JSON container. It corresponds to the last element of the non-reversed container.
|
||||
|
||||

|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Reverse iterator to the first element.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## See also
|
||||
|
||||
- [**rend**, **crend**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::rend)<br>
|
||||
returns a reverse iterator to the end
|
||||
@@ -1,32 +0,0 @@
|
||||
```cpp
|
||||
iterator rend();
|
||||
const_iterator rend() const;
|
||||
const_iterator crend() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns a reverse iterator to the element following the last element of the reversed JSON container. It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
||||
|
||||

|
||||
|
||||
## Parameters
|
||||
|
||||
None.
|
||||
|
||||
## Return value
|
||||
|
||||
Reverse iterator to the element following the last element.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## See also
|
||||
|
||||
- [**rbegin**, **crbegin**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::rbegin)<br>
|
||||
returns a reverse iterator to the beginning
|
||||
@@ -1,61 +0,0 @@
|
||||
```cpp
|
||||
size_type size() const;
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns the number of elements of a JSON value, i.e. `std::distance(begin(), end())`.
|
||||
|
||||
## Return value
|
||||
|
||||
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::size()` |
|
||||
| array | `ArrayType::size()` |
|
||||
|
||||
## Parameter
|
||||
|
||||
None.
|
||||
|
||||
## Complexity
|
||||
|
||||
Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container).
|
||||
|
||||
## Exceptions
|
||||
|
||||
None. The function's noexcept-specification is `noexcept`.
|
||||
|
||||
## Example
|
||||
|
||||
The following code uses empty to check if a `nlohmann::json` contains any elements:
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <json.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
nlohmann::json values {"string", true, 17, 23.42};
|
||||
|
||||
std::cout << "values contains " << values.size() << " elements.\n";
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
values contains 4 elements.
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [**empty**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::empty)<br>
|
||||
checks whether the container is empty
|
||||
- [**max_size**](https://github.com/nlohmann/json/wiki/nlohmann::basic_json::max_size)<br>
|
||||
returns the maximum possible number of elements
|
||||
@@ -1,11 +0,0 @@
|
||||
```cpp
|
||||
~basic_json();
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Destructs the container. The destructors of the elements are called and the used storage is deallocated.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the size of the container.
|
||||
Reference in new issue
Block a user