JSON for Modern C++ 2.0.10

allocator_type
array
array_t
at
at
at
at
at
at
back
back
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
begin
begin
boolean_t
cbegin
cend
clear
const_iterator
const_pointer
const_reference
const_reverse_iterator
count
crbegin
crend
diff
difference_type
dump
emplace
emplace_back
empty
end
end
erase
erase
erase
erase
find
find
flatten
from_cbor
from_msgpack
front
front
get
get
get
get_allocator
get_ptr
get_ptr
get_ref
get_ref
insert
insert
insert
insert
insert
is_array
is_boolean
is_discarded
is_null
is_number
is_number_float
is_number_integer
is_number_unsigned
is_object
is_primitive
is_string
is_structured
iterator
iterator_wrapper
iterator_wrapper
max_size
number_float_t
number_integer_t
number_unsigned_t
object
object_t
operator value_t
operator ValueType
operator!=
operator!=
operator!=
operator+=
operator+=
operator+=
operator+=
operator<
operator<
operator<<
operator<<
operator<=
operator=
operator==
operator==
operator==
operator>
operator>=
operator>>
operator>>
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
parse
parse
parse
parse
parse
parse
parse_event_t
parser_callback_t
patch
pointer
push_back
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
size
size_type
string_t
swap
swap
swap
swap
to_cbor
to_msgpack
type
unflatten
value
value
value
value
value_t
value_type
~basic_json
| ## § basic_json() [1/23] 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>
nlohmann::basic_json::basic_json | ( | const value_t | value_type | ) |
| inline
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 Constant. Exceptions
  std::bad_alloc | if allocation for object, array, or string value fails
  Example The following code shows the constructor for different value_t values 1 #include <json.hpp> 2 3 using json = nlohmann::json; 4 5 int main() 6 { 7 // create the different JSON values with default values 8 json j_null(json::value_t::null); 9 json j_boolean(json::value_t::boolean); 10 json j_number_integer(json::value_t::number_integer); 11 json j_number_float(json::value_t::number_float); 12 json j_object(json::value_t::object); 13 json j_array(json::value_t::array); 14 json j_string(json::value_t::string); 15 16 // serialize the JSON values 17 std::cout << j_null << '\n'; 18 std::cout << j_boolean << '\n'; 19 std::cout << j_number_integer << '\n'; 20 std::cout << j_number_float << '\n'; 21 std::cout << j_object << '\n'; 22 std::cout << j_array << '\n'; 23 std::cout << j_string << '\n'; 24 } nlohmann::json basic_json<> json default JSON class Definition: json.hpp:12151 nlohmann::basic_json::value_t::object object (unordered set of name/value pairs) nlohmann::basic_json::value_t::string string value nlohmann::basic_json::value_t::array array (ordered collection of values) nlohmann::basic_json::value_t::null null value nlohmann::basic_json::value_t::number_float number value (floating-point) nlohmann::basic_json::value_t::boolean boolean value nlohmann::basic_json::value_t::number_integer number value (signed integer) 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
See also basic_json(std::nullptr_t) – create a `null` value basic_json(boolean_t value) – create a boolean value basic_json(const string_t&) – create a string value basic_json(const object_t&) – create a object value basic_json(const array_t&) – create a array value basic_json(const number_float_t) – create a number (floating-point) value basic_json(const number_integer_t) – create a number (integer) value basic_json(const number_unsigned_t) – create a number (unsigned) value Since version 1.0.0 Definition at line 1070 of file json.hpp.