WhisperCom/doc/mkdocs/docs/api/basic_json/clear.md
Dominik Meyer cc002ebfbb Squashed 'libs/json/' content from commit f42a74b8
git-subtree-dir: libs/json
git-subtree-split: f42a74b8f53cc308647123d49d33d1c8122e3f42
2021-08-22 01:28:31 +02:00

1.1 KiB

basic_json::clear

void clear() noexcept;

Clears the content of a JSON value and resets it to the default value as if basic_json(value_t) would have been called with the current value type from type():

Value type initial value
null null
boolean false
string ""
number 0
binary An empty byte vector
object {}
array []

Has the same effect as calling

*this = basic_json(type());

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Linear in the size of the JSON value.

Notes

All iterators, pointers and references related to this container are invalidated.

Example

??? example

The example below shows the effect of `clear()` to different
JSON types.

```cpp
--8<-- "examples/clear.cpp"
```

Output:

```json
--8<-- "examples/clear.output"
```

Version history

  • Added in version 1.0.0.
  • Added support for binary types in version 3.8.0.