template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::clear |
( |
| ) |
|
|
inlinenoexcept |
clears the contents
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 | [] |
- Postcondition
- Has the same effect as calling
basic_json(const value_t v)
create an empty value with a given type
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
@liveexample{The example below shows the effect of clear()
to different JSON types.,clear}
@complexity Linear in the size of the JSON value.
@iterators All iterators, pointers and references related to this container are invalidated.
@exceptionsafety No-throw guarantee: this function never throws exceptions.
- See also
- see basic_json(value_t) – constructor that creates an object with the same value than calling
clear()
- Since
- version 1.0.0
Definition at line 23069 of file json.hpp.
23070 {
23071 switch (m_type)
23072 {
23074 {
23076 break;
23077 }
23078
23080 {
23082 break;
23083 }
23084
23086 {
23088 break;
23089 }
23090
23092 {
23094 break;
23095 }
23096
23098 {
23100 break;
23101 }
23102
23104 {
23106 break;
23107 }
23108
23110 {
23112 break;
23113 }
23114
23116 {
23118 break;
23119 }
23120
23123 default:
23124 break;
23125 }
23126 }
json_value m_value
the value of the current element
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)