|
◆ basic_json() [1/9]
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>
Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends on the type:
Value type | initial value |
null | null |
boolean | false |
string | "" |
number | 0 |
object | {} |
array | [] |
- Parameters
-
[in] | value_type | the type of the value to create |
- Complexity\n Constant.
- Exceptions
-
std::bad_alloc | if allocation for object, array, or string value fails |
- Example\n The following code shows the constructor for different @ref
- value_t values
17 std::cout << j_null << '\n';
static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >()) explicitly create an array from an initializer list
static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >()) explicitly create an object from an initializer list
a class to store JSON values
basic_json<> json default JSON class
Output (play with this example online):
null
false
0
0.0
{}
[]
""
The example code above can be translated with g++ -std=c++11 -Isrc doc/examples/basic_json__value_t.cpp -o basic_json__value_t
- Since
- version 1.0.0
Definition at line 1916 of file json.hpp.
|