JSON for Modern C++ 3.7.1

accept
accept
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
begin
begin
boolean_t
cbegin
cend
clear
const_iterator
const_pointer
const_reference
const_reverse_iterator
contains
contains
count
crbegin
crend
detail::external_constructor
diff
difference_type
dump
emplace
emplace_back
empty
end
end
erase
erase
erase
erase
error_handler_t
exception
find
find
flatten
from_bson
from_bson
from_cbor
from_cbor
from_msgpack
from_msgpack
from_ubjson
from_ubjson
front
front
get
get
get
get
get
get
get_allocator
get_ptr
get_ptr
get_ref
get_ref
get_to
get_to
initializer_list_t
input_format_t
insert
insert
insert
insert
insert
insert
insert_iterator
invalid_iterator
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
items
items
iterator
iterator_wrapper
iterator_wrapper
json_pointer
json_sax_t
json_serializer
max_size
merge_patch
meta
number_float_t
number_integer_t
number_unsigned_t
object
object_comparator_t
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[]
operator[]
operator[]
operator[]
operator[]
operator[]
other_error
out_of_range
parse
parse
parse_error
parse_event_t
parser_callback_t
patch
pointer
push_back
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
sax_parse
sax_parse
size
size_type
string_t
swap
swap
swap
swap
to_bson
to_bson
to_bson
to_cbor
to_cbor
to_cbor
to_msgpack
to_msgpack
to_msgpack
to_ubjson
to_ubjson
to_ubjson
type
type_error
type_name
unflatten
update
update
value
value
value
value
value_t
value_type
~basic_json
| ## ◆ get_ref() [1/2] 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> template<typename ReferenceType , typename std::enable_if< std::is_reference< ReferenceType >::value, int >::type = 0>
ReferenceType nlohmann::basic_json::get_ref | ( |  | ) |
| inline
  Implicit reference access to the internally stored JSON value. No copies are made. Warning Writing data to the referee of the result yields an undefined state. Template Parameters
  ReferenceType | reference type; must be a reference to array_t, object_t, string_t, boolean_t, number_integer_t, or number_float_t. Enforced by static assertion.
  Returns reference to the internally stored JSON value if the requested reference type ReferenceType fits to the JSON value; throws type_error.303 otherwise Exceptions
  type_error.303 | in case passed type ReferenceType is incompatible with the stored JSON value; see example below
  Complexity Constant. Example The example shows several calls to `get_ref()`. 1 #include <iostream> 2 #include <nlohmann/json.hpp> 3 4 using json = nlohmann::json; 5 6 int main() 7 { 8 // create a JSON number 9 json value = 17; 10 11 // explicitly getting references 12 auto r1 = value.get_ref<const json::number_integer_t&>(); 13 auto r2 = value.get_ref<json::number_integer_t&>(); 14 15 // print the values 16 std::cout << r1 << ' ' << r2 << '\n'; 17 18 // incompatible type throws exception 19 try 20 { 21 auto r3 = value.get_ref<json::number_float_t&>(); 22 } 23 catch (json::type_error& ex) 24 { 25 std::cout << ex.what() << '\n'; 26 } 27 } Output (play with this example online):
      17 17
      [json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
  The example code above can be translated with
      g++ -std=c++11 -Isingle_include doc/examples/get_ref.cpp -o get_ref
Since version 1.1.0 Definition at line 17367 of file json.hpp.

nlohmann::basic_json::value
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:17966
nlohmann::basic_json::number_integer_t
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:15223
nlohmann::basic_json::number_float_t
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:15362
nlohmann::basic_json::type_error
detail::type_error type_error
exception indicating executing a member function with a wrong type
Definition: json.hpp:14780
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:2445