JSON for Modern C++ 1.0.0-rc1

- Main Page
- Classes

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[]
operator[]
operator[]
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_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::operator value_t | ( |  | ) | const
| inlinenoexcept
  Implicitly return the type of the JSON value as a value from the value_t enumeration. Returns the type of the JSON value Complexity Constant. Example The following code exemplifies the value_t operator for all JSON types. 1 #include <json.hpp> 2 3 using namespace nlohmann; 4 5 int main() 6 { 7 // create JSON values 8 json j_null; 9 json j_boolean = true; 10 json j_number_integer = 17; 11 json j_number_float = 23.42; 12 json j_object = {{"one", 1}, {"two", 2}}; 13 json j_array = {1, 2, 4, 8, 16}; 14 json j_string = "Hello, world"; 15 16 // call operator value_t() 17 json::value_t t_null = j_null; 18 json::value_t t_boolean = j_boolean; 19 json::value_t t_number_integer = j_number_integer; 20 json::value_t t_number_float = j_number_float; 21 json::value_t t_object = j_object; 22 json::value_t t_array = j_array; 23 json::value_t t_string = j_string; 24 25 // print types 26 std::cout << std::boolalpha; 27 std::cout << (t_null == json::value_t::null) << '\n'; 28 std::cout << (t_boolean == json::value_t::boolean) << '\n'; 29 std::cout << (t_number_integer == json::value_t::number_integer) << '\n'; 30 std::cout << (t_number_float == json::value_t::number_float) << '\n'; 31 std::cout << (t_object == json::value_t::object) << '\n'; 32 std::cout << (t_array == json::value_t::array) << '\n'; 33 std::cout << (t_string == json::value_t::string) << '\n'; 34 } nlohmann::basic_json a class to store JSON values Definition: json.hpp:182 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 value_t the JSON type enumeration Definition: json.hpp:574 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):
      true
      true
      true
      true
      true
      true
      true
  The example code above can be translated with
      g++ -std=c++11 -Isrc doc/examples/operator__value_t.cpp -o operator__value_t