allocator_type
array
array_t
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
begin
begin
boolean_t
cbegin
cend
clear
const_pointer
const_reference
const_reverse_iterator
count
crbegin
crend
difference_type
dump
empty
end
end
erase
erase
erase
erase
find
find
front
front
get
get
get
get_allocator
get_ptr
get_ptr
insert
insert
insert
insert
insert
is_array
is_boolean
is_discarded
is_null
is_number
is_number_float
is_number_integer
is_object
is_primitive
is_string
is_structured
max_size
number_float_t
number_integer_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[]
parse
parse
parse
parse_event_t
parser_callback_t
pointer
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
size
size_type
string_t
swap
swap
swap
swap
type
value
value
value_t
value_type
~basic_json

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 = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>

nlohmann::basic_json::basic_json | ( | const value_t | value | ) |

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 | 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
  #include <json.hpp>
  using namespace nlohmann;
  int main()
  {
  // create the different JSON values with default values
  json j_null(json::value_t::null);
  json j_boolean(json::value_t::boolean);
  json j_number_integer(json::value_t::number_integer);
  json j_number_float(json::value_t::number_float);
  json j_object(json::value_t::object);
  json j_array(json::value_t::array);
  json j_string(json::value_t::string);
  // serialize the JSON values
  std::cout << j_null << '\n';
  std::cout << j_boolean << '\n';
  std::cout << j_number_integer << '\n';
  std::cout << j_number_float << '\n';
  std::cout << j_object << '\n';
  std::cout << j_array << '\n';
  std::cout << j_string << '\n';
  }
  nlohmann::basic_json
  a class to store JSON values
  Definition: json.hpp:187
  nlohmann::basic_json::value_t::object
  object (unordered set of name/value pairs)
  nlohmann
  namespace for Niels Lohmann
  Definition: json.hpp:78
  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 (integer)
  Output (play with this example online):

      null
      false
      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

Since
  version 1.0

Definition at line 866 of file json.hpp.