|
Constructors of class basic_json, copy/move constructor, copy assignment, static functions creating objects, and the destructor.
|
static basic_json | array (std::initializer_list< basic_json > init=std::initializer_list< basic_json >()) |
| explicitly create an array from an initializer list More...
|
|
static basic_json | object (std::initializer_list< basic_json > init=std::initializer_list< basic_json >()) |
| explicitly create an object from an initializer list More...
|
|
| basic_json (const value_t value_type) |
| create an empty value with a given type More...
|
|
| basic_json (std::nullptr_t=nullptr) noexcept |
| create a null object More...
|
|
| basic_json (const object_t &val) |
| create an object (explicit) More...
|
|
template<class CompatibleObjectType , typename std::enable_if< std::is_constructible< typename object_t::key_type, typename CompatibleObjectType::key_type >::value andstd::is_constructible< basic_json, typename CompatibleObjectType::mapped_type >::value, int >::type = 0> |
| basic_json (const CompatibleObjectType &val) |
| create an object (implicit) More...
|
|
| basic_json (const array_t &val) |
| create an array (explicit) More...
|
|
template<class CompatibleArrayType , typename std::enable_if< not std::is_same< CompatibleArrayType, typename basic_json_t::iterator >::value andnot std::is_same< CompatibleArrayType, typename basic_json_t::const_iterator >::value andnot std::is_same< CompatibleArrayType, typename basic_json_t::reverse_iterator >::value andnot std::is_same< CompatibleArrayType, typename basic_json_t::const_reverse_iterator >::value andnot std::is_same< CompatibleArrayType, typename array_t::iterator >::value andnot std::is_same< CompatibleArrayType, typename array_t::const_iterator >::value andstd::is_constructible< basic_json, typename CompatibleArrayType::value_type >::value, int >::type = 0> |
| basic_json (const CompatibleArrayType &val) |
| create an array (implicit) More...
|
|
| basic_json (const string_t &val) |
| create a string (explicit) More...
|
|
| basic_json (const typename string_t::value_type *val) |
| create a string (explicit) More...
|
|
template<class CompatibleStringType , typename std::enable_if< std::is_constructible< string_t, CompatibleStringType >::value, int >::type = 0> |
| basic_json (const CompatibleStringType &val) |
| create a string (implicit) More...
|
|
| basic_json (boolean_t val) noexcept |
| create a boolean (explicit) More...
|
|
template<typename T , typename std::enable_if< not(std::is_same< T, int >::value) andstd::is_same< T, number_integer_t >::value, int >::type = 0> |
| basic_json (const number_integer_t val) noexcept |
| create an integer number (explicit) More...
|
|
| basic_json (const int val) noexcept |
| create an integer number from an enum type (explicit) More...
|
|
template<typename CompatibleNumberIntegerType , typename std::enable_if< std::is_constructible< number_integer_t, CompatibleNumberIntegerType >::value andstd::numeric_limits< CompatibleNumberIntegerType >::is_integer andstd::numeric_limits< CompatibleNumberIntegerType >::is_signed, CompatibleNumberIntegerType >::type = 0> |
| basic_json (const CompatibleNumberIntegerType val) noexcept |
| create an integer number (implicit) More...
|
|
template<typename T , typename std::enable_if< not(std::is_same< T, int >::value) andstd::is_same< T, number_unsigned_t >::value, int >::type = 0> |
| basic_json (const number_unsigned_t val) noexcept |
| create an unsigned integer number (explicit) More...
|
|
template<typename CompatibleNumberUnsignedType , typename std::enable_if< std::is_constructible< number_unsigned_t, CompatibleNumberUnsignedType >::value andstd::numeric_limits< CompatibleNumberUnsignedType >::is_integer andnot std::numeric_limits< CompatibleNumberUnsignedType >::is_signed, CompatibleNumberUnsignedType >::type = 0> |
| basic_json (const CompatibleNumberUnsignedType val) noexcept |
| create an unsigned number (implicit) More...
|
|
| basic_json (const number_float_t val) noexcept |
| create a floating-point number (explicit) More...
|
|
template<typename CompatibleNumberFloatType , typename = typename std::enable_if< std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and std::is_floating_point<CompatibleNumberFloatType>::value>::type> |
| basic_json (const CompatibleNumberFloatType val) noexcept |
| create an floating-point number (implicit) More...
|
|
| basic_json (std::initializer_list< basic_json > init, bool type_deduction=true, value_t manual_type=value_t::array) |
| create a container (array or object) from an initializer list More...
|
|
| basic_json (size_type cnt, const basic_json &val) |
| construct an array with count copies of given value More...
|
|
template<class InputIT , typename std::enable_if< std::is_same< InputIT, typename basic_json_t::iterator >::value orstd::is_same< InputIT, typename basic_json_t::const_iterator >::value, int >::type = 0> |
| basic_json (InputIT first, InputIT last) |
| construct a JSON container given an iterator range More...
|
|
JSON_DEPRECATED | basic_json (std::istream &i, const parser_callback_t cb=nullptr) |
| construct a JSON value given an input stream More...
|
|
| basic_json (const basic_json &other) |
| copy constructor More...
|
|
| basic_json (basic_json &&other) noexcept |
| move constructor More...
|
|
reference & | operator= (basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value andstd::is_nothrow_move_assignable< value_t >::value andstd::is_nothrow_move_constructible< json_value >::value andstd::is_nothrow_move_assignable< json_value >::value) |
| copy assignment More...
|
|
| ~basic_json () |
| destructor More...
|
|
|
Direct access to the stored value of a JSON value.
|
template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value, int >::type = 0> |
ValueType | get () const |
| get a value (explicit) More...
|
|
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0> |
PointerType | get () noexcept |
| get a pointer value (explicit) More...
|
|
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0> |
constexpr const PointerType | get () const noexcept |
| get a pointer value (explicit) More...
|
|
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0> |
PointerType | get_ptr () noexcept |
| get a pointer value (implicit) More...
|
|
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value andstd::is_const< typename std::remove_pointer< PointerType >::type >::value, int >::type = 0> |
constexpr const PointerType | get_ptr () const noexcept |
| get a pointer value (implicit) More...
|
|
template<typename ReferenceType , typename std::enable_if< std::is_reference< ReferenceType >::value, int >::type = 0> |
ReferenceType | get_ref () |
| get a reference value (implicit) More...
|
|
template<typename ReferenceType , typename std::enable_if< std::is_reference< ReferenceType >::value andstd::is_const< typename std::remove_reference< ReferenceType >::type >::value, int >::type = 0> |
ReferenceType | get_ref () const |
| get a reference value (implicit) More...
|
|
template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value andnot std::is_same< ValueType, typename string_t::value_type >::valueand not std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>::value, int >::type = 0> |
| operator ValueType () const |
| get a value (implicit) More...
|
|
|
Access to the JSON value.
|
reference | at (size_type idx) |
| access specified array element with bounds checking More...
|
|
const_reference | at (size_type idx) const |
| access specified array element with bounds checking More...
|
|
reference | at (const typename object_t::key_type &key) |
| access specified object element with bounds checking More...
|
|
const_reference | at (const typename object_t::key_type &key) const |
| access specified object element with bounds checking More...
|
|
reference | operator[] (size_type idx) |
| access specified array element More...
|
|
const_reference | operator[] (size_type idx) const |
| access specified array element More...
|
|
reference | operator[] (const typename object_t::key_type &key) |
| access specified object element More...
|
|
const_reference | operator[] (const typename object_t::key_type &key) const |
| read-only access specified object element More...
|
|
template<typename T , std::size_t n> |
reference | operator[] (T *(&key)[n]) |
| access specified object element More...
|
|
template<typename T , std::size_t n> |
const_reference | operator[] (T *(&key)[n]) const |
| read-only access specified object element More...
|
|
template<typename T > |
reference | operator[] (T *key) |
| access specified object element More...
|
|
template<typename T > |
const_reference | operator[] (T *key) const |
| read-only access specified object element More...
|
|
template<class ValueType , typename std::enable_if< std::is_convertible< basic_json_t, ValueType >::value, int >::type = 0> |
ValueType | value (const typename object_t::key_type &key, ValueType default_value) const |
| access specified object element with default value More...
|
|
string_t | value (const typename object_t::key_type &key, const char *default_value) const |
| overload for a default value of type const char* More...
|
|
template<class ValueType , typename std::enable_if< std::is_convertible< basic_json_t, ValueType >::value, int >::type = 0> |
ValueType | value (const json_pointer &ptr, ValueType default_value) const |
| access specified object element via JSON Pointer with default value More...
|
|
string_t | value (const json_pointer &ptr, const char *default_value) const |
| overload for a default value of type const char* More...
|
|
reference | front () |
| access the first element More...
|
|
const_reference | front () const |
| access the first element More...
|
|
reference | back () |
| access the last element More...
|
|
const_reference | back () const |
| access the last element More...
|
|
template<class IteratorType , typename std::enable_if< std::is_same< IteratorType, typename basic_json_t::iterator >::value orstd::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int >::type = 0> |
IteratorType | erase (IteratorType pos) |
| remove element given an iterator More...
|
|
template<class IteratorType , typename std::enable_if< std::is_same< IteratorType, typename basic_json_t::iterator >::value orstd::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int >::type = 0> |
IteratorType | erase (IteratorType first, IteratorType last) |
| remove elements given an iterator range More...
|
|
size_type | erase (const typename object_t::key_type &key) |
| remove element from a JSON object given a key More...
|
|
void | erase (const size_type idx) |
| remove element from a JSON array given an index More...
|
|
|
bool | operator< (const value_t lhs, const value_t rhs) noexcept |
| comparison operator for JSON types More...
|
|
bool | operator== (const_reference lhs, const_reference rhs) noexcept |
| comparison: equal More...
|
|
bool | operator== (const_reference v, std::nullptr_t) noexcept |
| comparison: equal More...
|
|
bool | operator== (std::nullptr_t, const_reference v) noexcept |
| comparison: equal More...
|
|
bool | operator!= (const_reference lhs, const_reference rhs) noexcept |
| comparison: not equal More...
|
|
bool | operator!= (const_reference v, std::nullptr_t) noexcept |
| comparison: not equal More...
|
|
bool | operator!= (std::nullptr_t, const_reference v) noexcept |
| comparison: not equal More...
|
|
bool | operator< (const_reference lhs, const_reference rhs) noexcept |
| comparison: less than More...
|
|
bool | operator<= (const_reference lhs, const_reference rhs) noexcept |
| comparison: less than or equal More...
|
|
bool | operator> (const_reference lhs, const_reference rhs) noexcept |
| comparison: greater than More...
|
|
bool | operator>= (const_reference lhs, const_reference rhs) noexcept |
| comparison: greater than or equal More...
|
|
|
template<class T , std::size_t N> |
static basic_json | parse (T(&array)[N], const parser_callback_t cb=nullptr) |
| deserialize from an array More...
|
|
template<typename CharPT , typename std::enable_if< std::is_pointer< CharPT >::value andstd::is_integral< typename std::remove_pointer< CharPT >::type >::value andsizeof(typename std::remove_pointer< CharPT >::type)==1, int >::type = 0> |
static basic_json | parse (const CharPT s, const parser_callback_t cb=nullptr) |
| deserialize from string literal More...
|
|
static basic_json | parse (std::istream &i, const parser_callback_t cb=nullptr) |
| deserialize from stream More...
|
|
static basic_json | parse (std::istream &&i, const parser_callback_t cb=nullptr) |
| deserialize from stream More...
|
|
template<class IteratorType , typename std::enable_if< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< IteratorType >::iterator_category >::value, int >::type = 0> |
static basic_json | parse (IteratorType first, IteratorType last, const parser_callback_t cb=nullptr) |
| deserialize from an iterator range with contiguous storage More...
|
|
template<class ContiguousContainer , typename std::enable_if< not std::is_pointer< ContiguousContainer >::value andstd::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(std::begin(std::declval< ContiguousContainer const >()))>::iterator_category >::value, int >::type = 0> |
static basic_json | parse (const ContiguousContainer &c, const parser_callback_t cb=nullptr) |
| deserialize from a container with contiguous storage More...
|
|
std::istream & | operator<< (basic_json &j, std::istream &i) |
| deserialize from stream More...
|
|
std::istream & | operator>> (std::istream &i, basic_json &j) |
| deserialize from stream More...
|
|
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>
class nlohmann::basic_json
- Template Parameters
-
ObjectType | type for JSON objects (std::map by default; will be used in object_t) |
ArrayType | type for JSON arrays (std::vector by default; will be used in array_t) |
StringType | type for JSON strings and object keys (std::string by default; will be used in string_t) |
BooleanType | type for JSON booleans (bool by default; will be used in boolean_t) |
NumberIntegerType | type for JSON integer numbers (int64_t by default; will be used in number_integer_t) |
NumberUnsignedType | type for JSON unsigned integer numbers (uint64_t by default; will be used in number_unsigned_t) |
NumberFloatType | type for JSON floating-point numbers (double by default; will be used in number_float_t) |
AllocatorType | type of the allocator to use (std::allocator by default) |
- Requirements
- The class satisfies the following concept requirements:
- Basic
- Layout
- StandardLayoutType: JSON values have standard layout: All non-static data members are private and standard layout types, the class has no virtual functions or (virtual) base classes.
- Library-wide
- Container
- Container: JSON values can be used like STL containers and provide iterator access.
- ReversibleContainer; JSON values can be used like STL containers and provide reverse iterator access.
- Invariant
- The member variables m_value and m_type have the following relationship:
- If
m_type == value_t::object
, then m_value.object != nullptr
.
- If
m_type == value_t::array
, then m_value.array != nullptr
.
- If
m_type == value_t::string
, then m_value.string != nullptr
. The invariants are checked by member function assert_invariant().
- See also
- RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format
- Since
- version 1.0.0
Definition at line 231 of file json.hpp.