Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
nlohmann::basic_json Class Reference

a class to store JSON values More...

#include <json.hpp>

Public Types

using cbor_tag_handler_t = detail::cbor_tag_handler_t
 how to treat CBOR tags More...
 
using error_handler_t = detail::error_handler_t
 how to treat decoding errors More...
 
using initializer_list_t = std::initializer_list< detail::json_ref< basic_json > >
 helper type for initializer lists of basic_json values More...
 
using input_format_t = detail::input_format_t
 
using json_pointer = ::nlohmann::json_pointer< basic_json >
 JSON Pointer, see nlohmann::json_pointer. More...
 
using json_sax_t = json_sax< basic_json >
 SAX interface type, see nlohmann::json_sax. More...
 
template<typename T , typename SFINAE >
using json_serializer = JSONSerializer< T, SFINAE >
 
using parse_event_t = detail::parse_event_t
 parser event types More...
 
using parser_callback_t = detail::parser_callback_t< basic_json >
 per-element parser callback type More...
 
using value_t = detail::value_t
 

Public Member Functions

const JSON_HEDLEY_RETURNS_NON_NULL char * type_name () const noexcept
 return the type as string More...
 

Static Public Member Functions

static allocator_type get_allocator ()
 returns the allocator associated with the container More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta ()
 returns version information on the library More...
 

Public Attributes

JSON_PRIVATE_UNLESS_TESTED __pad3__: value_t m_type = value_t::null
 
json_value m_value = {}
 the value of the current element More...
 

Private Types

using basic_json_t = NLOHMANN_BASIC_JSON_TPL
 workaround type for MSVC More...
 
template<typename InputType >
using binary_reader = ::nlohmann::detail::binary_reader< basic_json, InputType >
 
template<typename CharType >
using binary_writer = ::nlohmann::detail::binary_writer< basic_json, CharType >
 
template<typename BasicJsonType >
using internal_iterator = ::nlohmann::detail::internal_iterator< BasicJsonType >
 
template<typename BasicJsonType >
using iter_impl = ::nlohmann::detail::iter_impl< BasicJsonType >
 
template<typename Iterator >
using iteration_proxy = ::nlohmann::detail::iteration_proxy< Iterator >
 
template<typename Base >
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator< Base >
 
template<typename CharType >
using output_adapter_t = ::nlohmann::detail::output_adapter_t< CharType >
 
using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t
 

Private Member Functions

void assert_invariant (bool check_parents=true) const noexcept
 checks the class invariants More...
 
void destroy (value_t t)
 
boolean_t get_impl (boolean_t *) const
 get a boolean (explicit) More...
 
array_tget_impl_ptr (array_t *) noexcept
 get a pointer to the value (array) More...
 
binary_tget_impl_ptr (binary_t *) noexcept
 get a pointer to the value (binary) More...
 
boolean_tget_impl_ptr (boolean_t *) noexcept
 get a pointer to the value (boolean) More...
 
constexpr const array_tget_impl_ptr (const array_t *) const noexcept
 get a pointer to the value (array) More...
 
constexpr const binary_tget_impl_ptr (const binary_t *) const noexcept
 get a pointer to the value (binary) More...
 
constexpr const boolean_tget_impl_ptr (const boolean_t *) const noexcept
 get a pointer to the value (boolean) More...
 
constexpr const number_float_tget_impl_ptr (const number_float_t *) const noexcept
 get a pointer to the value (floating-point number) More...
 
constexpr const number_integer_tget_impl_ptr (const number_integer_t *) const noexcept
 get a pointer to the value (integer number) More...
 
constexpr const number_unsigned_tget_impl_ptr (const number_unsigned_t *) const noexcept
 get a pointer to the value (unsigned number) More...
 
constexpr const object_tget_impl_ptr (const object_t *) const noexcept
 get a pointer to the value (object) More...
 
constexpr const string_tget_impl_ptr (const string_t *) const noexcept
 get a pointer to the value (string) More...
 
number_float_tget_impl_ptr (number_float_t *) noexcept
 get a pointer to the value (floating-point number) More...
 
number_integer_tget_impl_ptr (number_integer_t *) noexcept
 get a pointer to the value (integer number) More...
 
number_unsigned_tget_impl_ptr (number_unsigned_t *) noexcept
 get a pointer to the value (unsigned number) More...
 
object_tget_impl_ptr (object_t *) noexcept
 get a pointer to the value (object) More...
 
string_tget_impl_ptr (string_t *) noexcept
 get a pointer to the value (string) More...
 
 json_value ()=default
 default constructor (for null values) More...
 
 json_value (array_t &&value)
 constructor for rvalue arrays More...
 
 json_value (binary_t &&value)
 constructor for rvalue binary arrays (internal type) More...
 
 json_value (boolean_t v) noexcept
 constructor for booleans More...
 
 json_value (const array_t &value)
 constructor for arrays More...
 
 json_value (const binary_t &value)
 constructor for binary arrays (internal type) More...
 
 json_value (const object_t &value)
 constructor for objects More...
 
 json_value (const string_t &value)
 constructor for strings More...
 
 json_value (const typename binary_t::container_type &value)
 constructor for binary arrays More...
 
 json_value (number_float_t v) noexcept
 constructor for numbers (floating-point) More...
 
 json_value (number_integer_t v) noexcept
 constructor for numbers (integer) More...
 
 json_value (number_unsigned_t v) noexcept
 constructor for numbers (unsigned) More...
 
 json_value (object_t &&value)
 constructor for rvalue objects More...
 
 json_value (string_t &&value)
 constructor for rvalue strings More...
 
 json_value (typename binary_t::container_type &&value)
 constructor for rvalue binary arrays More...
 
 json_value (value_t t)
 constructor for empty values of a given type More...
 
template<typename InputAdapterType >
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser (InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
 
reference set_parent (reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
 
void set_parents ()
 
iterator set_parents (iterator it, typename iterator::difference_type count_set_parents)
 

Static Private Member Functions

template<typename T , typename... Args>
static JSON_HEDLEY_RETURNS_NON_NULL T * create (Args &&... args)
 helper for exception-safe object creation More...
 
template<typename ReferenceType , typename ThisType >
static ReferenceType get_ref_impl (ThisType &obj)
 helper function to implement get_ref() More...
 

Private Attributes

JSON_PRIVATE_UNLESS_TESTED __pad0__: using lexer = ::nlohmann::detail::lexer_base<basic_json>
 
JSON_PRIVATE_UNLESS_TESTED __pad1__: using serializer = ::nlohmann::detail::serializer<basic_json>
 
JSON_PRIVATE_UNLESS_TESTED __pad2__: union json_value { object_t* object
 
array_tarray
 array (stored with pointer to save storage) More...
 
binary_tbinary
 binary (stored with pointer to save storage) More...
 
boolean_t boolean
 boolean More...
 
number_float_t number_float
 number (floating-point) More...
 
number_integer_t number_integer
 number (integer) More...
 
number_unsigned_t number_unsigned
 number (unsigned integer) More...
 
string_tstring
 string (stored with pointer to save storage) More...
 

Friends

template<typename BasicJsonType , typename InputType , typename SAX >
class ::nlohmann::detail::binary_reader
 
template<typename BasicJsonType , typename CharType >
class ::nlohmann::detail::binary_writer
 
class ::nlohmann::detail::exception
 
template<typename BasicJsonType >
class ::nlohmann::detail::iter_impl
 
template<typename BasicJsonType >
class ::nlohmann::detail::json_sax_dom_callback_parser
 
template<typename BasicJsonType >
class ::nlohmann::detail::json_sax_dom_parser
 
template<typename BasicJsonType , typename InputType >
class ::nlohmann::detail::parser
 
template<detail::value_t >
struct detail::external_constructor
 

exceptions

Classes to implement user-defined exceptions.

using exception = detail::exception
 
using parse_error = detail::parse_error
 
using invalid_iterator = detail::invalid_iterator
 
using type_error = detail::type_error
 
using out_of_range = detail::out_of_range
 
using other_error = detail::other_error
 

container types

The canonic container types to use basic_json like any other STL container.

using value_type = basic_json
 the type of elements in a basic_json container More...
 
using reference = value_type &
 the type of an element reference More...
 
using const_reference = const value_type &
 the type of an element const reference More...
 
using difference_type = std::ptrdiff_t
 a type to represent differences between iterators More...
 
using size_type = std::size_t
 a type to represent container sizes More...
 
using allocator_type = AllocatorType< basic_json >
 the allocator type More...
 
using pointer = typename std::allocator_traits< allocator_type >::pointer
 the type of an element pointer More...
 
using const_pointer = typename std::allocator_traits< allocator_type >::const_pointer
 the type of an element const pointer More...
 
using iterator = iter_impl< basic_json >
 an iterator for a basic_json container More...
 
using const_iterator = iter_impl< const basic_json >
 a const iterator for a basic_json container More...
 
using reverse_iterator = json_reverse_iterator< typename basic_json::iterator >
 a reverse iterator for a basic_json container More...
 
using const_reverse_iterator = json_reverse_iterator< typename basic_json::const_iterator >
 a const reverse iterator for a basic_json container More...
 

JSON value data types

The data types to store a JSON value. These types are derived from the template arguments passed to class basic_json.

using object_comparator_t = std::less< StringType >
 object key comparator type More...
 
using object_t = ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >>
 a type for an object More...
 
using array_t = ArrayType< basic_json, AllocatorType< basic_json > >
 a type for an array More...
 
using string_t = StringType
 a type for a string More...
 
using boolean_t = BooleanType
 a type for a boolean More...
 
using number_integer_t = NumberIntegerType
 a type for a number (integer) More...
 
using number_unsigned_t = NumberUnsignedType
 a type for a number (unsigned) More...
 
using number_float_t = NumberFloatType
 a type for a number (floating-point) More...
 
using binary_t = nlohmann::byte_container_with_subtype< BinaryType >
 a type for a packed binary type More...
 

constructors and destructors

Constructors of class basic_json, copy/move constructor, copy assignment, static functions creating objects, and the destructor.

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (const typename binary_t::container_type &init)
 explicitly create a binary array (without subtype) More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
 explicitly create a binary array (with subtype) More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (typename binary_t::container_type &&init)
 explicitly create a binary array More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
 explicitly create a binary array (with subtype) More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array (initializer_list_t init={})
 explicitly create an array from an initializer list More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object (initializer_list_t init={})
 explicitly create an object from an initializer list More...
 
 basic_json (const value_t v)
 create an empty value with a given type More...
 
 basic_json (std::nullptr_t=nullptr) noexcept
 create a null object More...
 
template<typename CompatibleType , typename U = detail::uncvref_t<CompatibleType>, detail::enable_if_t< !detail::is_basic_json< U >::value &&detail::is_compatible_type< basic_json_t, U >::value, int > = 0>
 basic_json (CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
 create a JSON value from compatible types More...
 
template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&!std::is_same< basic_json, BasicJsonType >::value, int > = 0>
 basic_json (const BasicJsonType &val)
 create a JSON value from an existing one More...
 
 basic_json (initializer_list_t 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||std::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...
 
template<typename JsonRef , detail::enable_if_t< detail::conjunction< detail::is_json_ref< JsonRef >, std::is_same< typename JsonRef::value_type, basic_json >>::value, int > = 0>
 basic_json (const JsonRef &ref)
 
 basic_json (const basic_json &other)
 copy constructor More...
 
 basic_json (basic_json &&other) noexcept
 move constructor More...
 
basic_jsonoperator= (basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
 copy assignment More...
 
 ~basic_json () noexcept
 destructor More...
 

object inspection

Functions to inspect the type of a JSON value.

string_t dump (const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
 serialization More...
 
constexpr value_t type () const noexcept
 return the type of the JSON value (explicit) More...
 
constexpr bool is_primitive () const noexcept
 return whether type is primitive More...
 
constexpr bool is_structured () const noexcept
 return whether type is structured More...
 
constexpr bool is_null () const noexcept
 return whether value is null More...
 
constexpr bool is_boolean () const noexcept
 return whether value is a boolean More...
 
constexpr bool is_number () const noexcept
 return whether value is a number More...
 
constexpr bool is_number_integer () const noexcept
 return whether value is an integer number More...
 
constexpr bool is_number_unsigned () const noexcept
 return whether value is an unsigned integer number More...
 
constexpr bool is_number_float () const noexcept
 return whether value is a floating-point number More...
 
constexpr bool is_object () const noexcept
 return whether value is an object More...
 
constexpr bool is_array () const noexcept
 return whether value is an array More...
 
constexpr bool is_string () const noexcept
 return whether value is a string More...
 
constexpr bool is_binary () const noexcept
 return whether value is a binary array More...
 
constexpr bool is_discarded () const noexcept
 return whether value is discarded More...
 
constexpr operator value_t () const noexcept
 return the type of the JSON value (implicit) More...
 

value access

Direct access to the stored value of a JSON value.

template<typename ValueType , detail::enable_if_t< detail::is_default_constructible< ValueType >::value &&detail::has_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType get_impl (detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
 get a value (explicit) More...
 
template<typename ValueType , detail::enable_if_t< detail::has_non_default_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType get_impl (detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
 get a value (explicit); special case More...
 
template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0>
BasicJsonType get_impl (detail::priority_tag< 2 >) const
 get special-case overload More...
 
template<typename BasicJsonType , detail::enable_if_t< std::is_same< BasicJsonType, basic_json_t >::value, int > = 0>
basic_json get_impl (detail::priority_tag< 3 >) const
 get special-case overload More...
 
template<typename PointerType , detail::enable_if_t< std::is_pointer< PointerType >::value, int > = 0>
constexpr auto get_impl (detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
 get a pointer value (explicit) More...
 
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0>
auto get_ptr () noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
 get a pointer value (implicit) More...
 
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value &&std::is_const< typename std::remove_pointer< PointerType >::type >::value, int >::type = 0>
constexpr auto get_ptr () const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
 get a pointer value (implicit) More...
 
template<typename ValueTypeCV , typename ValueType = detail::uncvref_t<ValueTypeCV>>
auto get () const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 >
 get a (pointer) value (explicit) More...
 
return get_impl (detail::priority_tag< 4 > {})
 
template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0>
auto get () noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
 get a pointer value (explicit) More...
 
template<typename ValueType , detail::enable_if_t< !detail::is_basic_json< ValueType >::value &&detail::has_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType & get_to (ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
 get a value (explicit) More...
 
template<typename ValueType , detail::enable_if_t< detail::is_basic_json< ValueType >::value, int > = 0>
ValueType & get_to (ValueType &v) const
 
template<typename T , std::size_t N, typename Array = T (&)[N], detail::enable_if_t< detail::has_from_json< basic_json_t, Array >::value, int > = 0>
Array get_to (T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
 
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 &&std::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< detail::conjunction< detail::negation< std::is_pointer< ValueType >>, detail::negation< std::is_same< ValueType, detail::json_ref< basic_json >>>, detail::negation< std::is_same< ValueType, typename string_t::value_type >>, detail::negation< detail::is_basic_json< ValueType >>, detail::negation< std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>>, detail::is_detected_lazy< detail::get_template_function, const basic_json_t &, ValueType > >::value, int >::type = 0>
JSON_EXPLICIT operator ValueType () const
 get a value (implicit) More...
 
binary_tget_binary ()
 get a binary value More...
 
const binary_tget_binary () const
 get a binary value More...
 

element access

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
 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
 access specified object element More...
 
template<class ValueType , typename std::enable_if< detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, ValueType >::value, int >::type = 0>
ValueType value (const typename object_t::key_type &key, const 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
 access specified object element with default value More...
 
template<class ValueType , typename std::enable_if< detail::is_getable< basic_json_t, ValueType >::value, int >::type = 0>
ValueType value (const json_pointer &ptr, const 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
 access specified object element via JSON Pointer with default value 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||std::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||std::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...
 

lookup

template<typename KeyT >
iterator find (KeyT &&key)
 find an element in a JSON object More...
 
template<typename KeyT >
const_iterator find (KeyT &&key) const
 find an element in a JSON object More...
 
template<typename KeyT >
size_type count (KeyT &&key) const
 returns the number of occurrences of a key in a JSON object More...
 
template<typename KeyT , typename std::enable_if< !std::is_same< typename std::decay< KeyT >::type, json_pointer >::value, int >::type = 0>
bool contains (KeyT &&key) const
 check the existence of an element in a JSON object More...
 
bool contains (const json_pointer &ptr) const
 check the existence of an element in a JSON object given a JSON pointer More...
 

iterators

static iteration_proxy< iteratoriterator_wrapper (reference ref) noexcept
 wrapper to access iterator member functions in range-based for More...
 
static iteration_proxy< const_iteratoriterator_wrapper (const_reference ref) noexcept
 wrapper to access iterator member functions in range-based for More...
 
iterator begin () noexcept
 returns an iterator to the first element More...
 
const_iterator begin () const noexcept
 returns an iterator to the first element More...
 
const_iterator cbegin () const noexcept
 returns a const iterator to the first element More...
 
iterator end () noexcept
 returns an iterator to one past the last element More...
 
const_iterator end () const noexcept
 returns an iterator to one past the last element More...
 
const_iterator cend () const noexcept
 returns an iterator to one past the last element More...
 
reverse_iterator rbegin () noexcept
 returns an iterator to the reverse-beginning More...
 
const_reverse_iterator rbegin () const noexcept
 returns an iterator to the reverse-beginning More...
 
reverse_iterator rend () noexcept
 returns an iterator to the reverse-end More...
 
const_reverse_iterator rend () const noexcept
 returns an iterator to the reverse-end More...
 
const_reverse_iterator crbegin () const noexcept
 returns a const reverse iterator to the last element More...
 
const_reverse_iterator crend () const noexcept
 returns a const reverse iterator to one before the first More...
 
iteration_proxy< iteratoritems () noexcept
 helper to access iterator member functions in range-based for More...
 
iteration_proxy< const_iteratoritems () const noexcept
 helper to access iterator member functions in range-based for More...
 

capacity

bool empty () const noexcept
 checks whether the container is empty. More...
 
size_type size () const noexcept
 returns the number of elements More...
 
size_type max_size () const noexcept
 returns the maximum possible number of elements More...
 

modifiers

void swap (reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
 exchanges the values More...
 
void clear () noexcept
 clears the contents More...
 
void push_back (basic_json &&val)
 add an object to an array More...
 
reference operator+= (basic_json &&val)
 add an object to an array More...
 
void push_back (const basic_json &val)
 add an object to an array More...
 
reference operator+= (const basic_json &val)
 add an object to an array More...
 
void push_back (const typename object_t::value_type &val)
 add an object to an object More...
 
reference operator+= (const typename object_t::value_type &val)
 add an object to an object More...
 
void push_back (initializer_list_t init)
 add an object to an object More...
 
reference operator+= (initializer_list_t init)
 add an object to an object More...
 
template<class... Args>
reference emplace_back (Args &&... args)
 add an object to an array More...
 
template<class... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 add an object to an object if key does not exist More...
 
template<typename... Args>
iterator insert_iterator (const_iterator pos, Args &&... args)
 
iterator insert (const_iterator pos, const basic_json &val)
 inserts element into array More...
 
iterator insert (const_iterator pos, basic_json &&val)
 inserts element into array More...
 
iterator insert (const_iterator pos, size_type cnt, const basic_json &val)
 inserts copies of element into array More...
 
iterator insert (const_iterator pos, const_iterator first, const_iterator last)
 inserts range of elements into array More...
 
iterator insert (const_iterator pos, initializer_list_t ilist)
 inserts elements from initializer list into array More...
 
void insert (const_iterator first, const_iterator last)
 inserts range of elements into object More...
 
void update (const_reference j, bool merge_objects=false)
 updates a JSON object from another object, overwriting existing keys More...
 
void update (const_iterator first, const_iterator last, bool merge_objects=false)
 updates a JSON object from another object, overwriting existing keys More...
 
void swap (reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
 exchanges the values More...
 
void swap (array_t &other)
 exchanges the values More...
 
void swap (object_t &other)
 exchanges the values More...
 
void swap (string_t &other)
 exchanges the values More...
 
void swap (binary_t &other)
 exchanges the values More...
 
void swap (typename binary_t::container_type &other)
 exchanges the values More...
 

lexicographical comparison operators

bool operator== (const_reference lhs, const_reference rhs) noexcept
 comparison: equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator== (const_reference lhs, ScalarType rhs) noexcept
 comparison: equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator== (ScalarType lhs, const_reference rhs) noexcept
 comparison: equal More...
 
bool operator!= (const_reference lhs, const_reference rhs) noexcept
 comparison: not equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator!= (const_reference lhs, ScalarType rhs) noexcept
 comparison: not equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator!= (ScalarType lhs, const_reference rhs) noexcept
 comparison: not equal More...
 
bool operator< (const_reference lhs, const_reference rhs) noexcept
 comparison: less than More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator< (const_reference lhs, ScalarType rhs) noexcept
 comparison: less than More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator< (ScalarType lhs, const_reference rhs) noexcept
 comparison: less than More...
 
bool operator<= (const_reference lhs, const_reference rhs) noexcept
 comparison: less than or equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator<= (const_reference lhs, ScalarType rhs) noexcept
 comparison: less than or equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator<= (ScalarType lhs, const_reference rhs) noexcept
 comparison: less than or equal More...
 
bool operator> (const_reference lhs, const_reference rhs) noexcept
 comparison: greater than More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator> (const_reference lhs, ScalarType rhs) noexcept
 comparison: greater than More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator> (ScalarType 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<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator>= (const_reference lhs, ScalarType rhs) noexcept
 comparison: greater than or equal More...
 
template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator>= (ScalarType lhs, const_reference rhs) noexcept
 comparison: greater than or equal More...
 

serialization

std::ostream & operator<< (std::ostream &o, const basic_json &j)
 serialize to stream More...
 
std::ostream & operator>> (const basic_json &j, std::ostream &o)
 serialize to stream More...
 

deserialization

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<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse (InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
 deserialize from a compatible input More...
 
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse (IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
 deserialize from a pair of character iterators More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse (detail::span_input_adapter &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
 
template<typename InputType >
static bool accept (InputType &&i, const bool ignore_comments=false)
 check if the input is valid JSON More...
 
template<typename IteratorType >
static bool accept (IteratorType first, IteratorType last, const bool ignore_comments=false)
 check if the input is valid JSON More...
 
static JSON_HEDLEY_WARN_UNUSED_RESULT bool accept (detail::span_input_adapter &&i, const bool ignore_comments=false)
 
template<typename InputType , typename SAX >
static bool sax_parse (InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
 generate SAX events More...
 
template<class IteratorType , class SAX >
static bool sax_parse (IteratorType first, IteratorType last, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
 generate SAX events More...
 
template<typename SAX >
static bool sax_parse (detail::span_input_adapter &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
 generate SAX events More...
 

binary serialization/deserialization support

static std::vector< std::uint8_t > to_cbor (const basic_json &j)
 create a CBOR serialization of a given JSON value More...
 
static void to_cbor (const basic_json &j, detail::output_adapter< std::uint8_t > o)
 create a CBOR serialization of a given JSON value More...
 
static void to_cbor (const basic_json &j, detail::output_adapter< char > o)
 create a CBOR serialization of a given JSON value More...
 
static std::vector< std::uint8_t > to_msgpack (const basic_json &j)
 create a MessagePack serialization of a given JSON value More...
 
static void to_msgpack (const basic_json &j, detail::output_adapter< std::uint8_t > o)
 create a MessagePack serialization of a given JSON value More...
 
static void to_msgpack (const basic_json &j, detail::output_adapter< char > o)
 create a MessagePack serialization of a given JSON value More...
 
static std::vector< std::uint8_t > to_ubjson (const basic_json &j, const bool use_size=false, const bool use_type=false)
 create a UBJSON serialization of a given JSON value More...
 
static void to_ubjson (const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
 create a UBJSON serialization of a given JSON value More...
 
static void to_ubjson (const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
 create a UBJSON serialization of a given JSON value More...
 
static std::vector< std::uint8_t > to_bson (const basic_json &j)
 create a BSON serialization of a given JSON value More...
 
static void to_bson (const basic_json &j, detail::output_adapter< std::uint8_t > o)
 create a BSON serialization of a given JSON value More...
 
static void to_bson (const basic_json &j, detail::output_adapter< char > o)
 create a BSON serialization of a given JSON value More...
 
template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
 create a JSON value from an input in CBOR format More...
 
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
 create a JSON value from an input in CBOR format More...
 
template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
 
template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (InputType &&i, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in MessagePack format More...
 
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in MessagePack format More...
 
template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
 
template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (InputType &&i, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in UBJSON format More...
 
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in UBJSON format More...
 
template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
 
template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (InputType &&i, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in BSON format More...
 
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
 create a JSON value from an input in BSON format More...
 
template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
 
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
 

JSON Pointer functions

reference operator[] (const json_pointer &ptr)
 access specified element via JSON Pointer More...
 
const_reference operator[] (const json_pointer &ptr) const
 access specified element via JSON Pointer More...
 
reference at (const json_pointer &ptr)
 access specified element via JSON Pointer More...
 
const_reference at (const json_pointer &ptr) const
 access specified element via JSON Pointer More...
 
basic_json flatten () const
 return flattened JSON value More...
 
basic_json unflatten () const
 unflatten a previously flattened JSON value More...
 

JSON Patch functions

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff (const basic_json &source, const basic_json &target, const std::string &path="")
 creates a diff as a JSON patch More...
 
basic_json patch (const basic_json &json_patch) const
 applies a JSON patch More...
 

JSON Merge Patch functions

void merge_patch (const basic_json &apply_patch)
 applies a JSON Merge Patch More...
 

Detailed Description

a class to store JSON values

a class to store JSON values

See also
https://json.nlohmann.me/api/basic_json/
Since
version 1.0.0

Definition at line 3326 of file json.hpp.

Member Typedef Documentation

◆ allocator_type

the allocator type

Definition at line 17399 of file json.hpp.

◆ array_t

using nlohmann::basic_json::array_t = ArrayType<basic_json, AllocatorType<basic_json> >

a type for an array

See also
https://json.nlohmann.me/api/basic_json/array_t/

Definition at line 17513 of file json.hpp.

◆ basic_json_t

workaround type for MSVC

Definition at line 17303 of file json.hpp.

◆ binary_reader

template<typename InputType >
using nlohmann::basic_json::binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>
private

Definition at line 17335 of file json.hpp.

◆ binary_t

a type for a packed binary type

See also
https://json.nlohmann.me/api/basic_json/binary_t/

Definition at line 17537 of file json.hpp.

◆ binary_writer

template<typename CharType >
using nlohmann::basic_json::binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>
private

Definition at line 17336 of file json.hpp.

◆ boolean_t

using nlohmann::basic_json::boolean_t = BooleanType

a type for a boolean

See also
https://json.nlohmann.me/api/basic_json/boolean_t/

Definition at line 17521 of file json.hpp.

◆ cbor_tag_handler_t

how to treat CBOR tags

Definition at line 17350 of file json.hpp.

◆ const_iterator

a const iterator for a basic_json container

Definition at line 17409 of file json.hpp.

◆ const_pointer

using nlohmann::basic_json::const_pointer = typename std::allocator_traits<allocator_type>::const_pointer

the type of an element const pointer

Definition at line 17404 of file json.hpp.

◆ const_reference

the type of an element const reference

Definition at line 17391 of file json.hpp.

◆ const_reverse_iterator

a const reverse iterator for a basic_json container

Definition at line 17413 of file json.hpp.

◆ difference_type

using nlohmann::basic_json::difference_type = std::ptrdiff_t

a type to represent differences between iterators

Definition at line 17394 of file json.hpp.

◆ error_handler_t

how to treat decoding errors

Definition at line 17348 of file json.hpp.

◆ exception

Definition at line 17366 of file json.hpp.

◆ initializer_list_t

helper type for initializer lists of basic_json values

Definition at line 17352 of file json.hpp.

◆ input_format_t

Definition at line 17354 of file json.hpp.

◆ internal_iterator

template<typename BasicJsonType >
using nlohmann::basic_json::internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>
private

Definition at line 17324 of file json.hpp.

◆ invalid_iterator

Definition at line 17368 of file json.hpp.

◆ iter_impl

template<typename BasicJsonType >
using nlohmann::basic_json::iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>
private

Definition at line 17326 of file json.hpp.

◆ iteration_proxy

template<typename Iterator >
using nlohmann::basic_json::iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>
private

Definition at line 17328 of file json.hpp.

◆ iterator

an iterator for a basic_json container

Definition at line 17407 of file json.hpp.

◆ json_pointer

JSON Pointer, see nlohmann::json_pointer.

Definition at line 17344 of file json.hpp.

◆ json_reverse_iterator

Definition at line 17329 of file json.hpp.

◆ json_sax_t

SAX interface type, see nlohmann::json_sax.

Definition at line 17356 of file json.hpp.

◆ json_serializer

template<typename T , typename SFINAE >
using nlohmann::basic_json::json_serializer = JSONSerializer<T, SFINAE>

Definition at line 17346 of file json.hpp.

◆ number_float_t

using nlohmann::basic_json::number_float_t = NumberFloatType

a type for a number (floating-point)

See also
https://json.nlohmann.me/api/basic_json/number_float_t/

Definition at line 17533 of file json.hpp.

◆ number_integer_t

using nlohmann::basic_json::number_integer_t = NumberIntegerType

a type for a number (integer)

See also
https://json.nlohmann.me/api/basic_json/number_integer_t/

Definition at line 17525 of file json.hpp.

◆ number_unsigned_t

using nlohmann::basic_json::number_unsigned_t = NumberUnsignedType

a type for a number (unsigned)

See also
https://json.nlohmann.me/api/basic_json/number_unsigned_t/

Definition at line 17529 of file json.hpp.

◆ object_comparator_t

using nlohmann::basic_json::object_comparator_t = std::less<StringType>

object key comparator type

See also
https://json.nlohmann.me/api/basic_json/object_comparator_t/

Definition at line 17500 of file json.hpp.

◆ object_t

using nlohmann::basic_json::object_t = ObjectType<StringType, basic_json, object_comparator_t, AllocatorType<std::pair<const StringType, basic_json> >>

a type for an object

See also
https://json.nlohmann.me/api/basic_json/object_t/

Definition at line 17509 of file json.hpp.

◆ other_error

Definition at line 17371 of file json.hpp.

◆ out_of_range

Definition at line 17370 of file json.hpp.

◆ output_adapter_t

template<typename CharType >
using nlohmann::basic_json::output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>
private

Definition at line 17332 of file json.hpp.

◆ parse_error

Definition at line 17367 of file json.hpp.

◆ parse_event_t

parser event types

See also
https://json.nlohmann.me/api/basic_json/parse_event_t/

Definition at line 17956 of file json.hpp.

◆ parser_callback_t

per-element parser callback type

See also
https://json.nlohmann.me/api/basic_json/parser_callback_t/

Definition at line 17960 of file json.hpp.

◆ pointer

using nlohmann::basic_json::pointer = typename std::allocator_traits<allocator_type>::pointer

the type of an element pointer

Definition at line 17402 of file json.hpp.

◆ primitive_iterator_t

Definition at line 17322 of file json.hpp.

◆ reference

the type of an element reference

Definition at line 17389 of file json.hpp.

◆ reverse_iterator

a reverse iterator for a basic_json container

Definition at line 17411 of file json.hpp.

◆ size_type

using nlohmann::basic_json::size_type = std::size_t

a type to represent container sizes

Definition at line 17396 of file json.hpp.

◆ string_t

using nlohmann::basic_json::string_t = StringType

a type for a string

See also
https://json.nlohmann.me/api/basic_json/string_t/

Definition at line 17517 of file json.hpp.

◆ type_error

Definition at line 17369 of file json.hpp.

◆ value_t

Definition at line 17342 of file json.hpp.

◆ value_type

the type of elements in a basic_json container

Definition at line 17386 of file json.hpp.

Constructor & Destructor Documentation

◆ basic_json() [1/10]

nlohmann::basic_json::basic_json ( const value_t  v)
inline

create an empty value with a given type

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 17973 of file json.hpp.

◆ basic_json() [2/10]

nlohmann::basic_json::basic_json ( std::nullptr_t  = nullptr)
inlinenoexcept

create a null object

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 17981 of file json.hpp.

◆ basic_json() [3/10]

template<typename CompatibleType , typename U = detail::uncvref_t<CompatibleType>, detail::enable_if_t< !detail::is_basic_json< U >::value &&detail::is_compatible_type< basic_json_t, U >::value, int > = 0>
nlohmann::basic_json::basic_json ( CompatibleType &&  val)
inlinenoexcept

create a JSON value from compatible types

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 17993 of file json.hpp.

◆ basic_json() [4/10]

template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&!std::is_same< basic_json, BasicJsonType >::value, int > = 0>
nlohmann::basic_json::basic_json ( const BasicJsonType &  val)
inline

create a JSON value from an existing one

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18007 of file json.hpp.

◆ basic_json() [5/10]

nlohmann::basic_json::basic_json ( initializer_list_t  init,
bool  type_deduction = true,
value_t  manual_type = value_t::array 
)
inline

create a container (array or object) from an initializer list

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18059 of file json.hpp.

◆ basic_json() [6/10]

nlohmann::basic_json::basic_json ( size_type  cnt,
const basic_json val 
)
inline

construct an array with count copies of given value

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18174 of file json.hpp.

◆ basic_json() [7/10]

template<class InputIT , typename std::enable_if< std::is_same< InputIT, typename basic_json_t::iterator >::value||std::is_same< InputIT, typename basic_json_t::const_iterator >::value, int >::type = 0>
nlohmann::basic_json::basic_json ( InputIT  first,
InputIT  last 
)
inline

construct a JSON container given an iterator range

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18187 of file json.hpp.

◆ basic_json() [8/10]

template<typename JsonRef , detail::enable_if_t< detail::conjunction< detail::is_json_ref< JsonRef >, std::is_same< typename JsonRef::value_type, basic_json >>::value, int > = 0>
nlohmann::basic_json::basic_json ( const JsonRef &  ref)
inline

Definition at line 18297 of file json.hpp.

◆ basic_json() [9/10]

nlohmann::basic_json::basic_json ( const basic_json other)
inline

copy constructor

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18301 of file json.hpp.

◆ basic_json() [10/10]

nlohmann::basic_json::basic_json ( basic_json &&  other)
inlinenoexcept

move constructor

See also
https://json.nlohmann.me/api/basic_json/basic_json/

Definition at line 18369 of file json.hpp.

◆ ~basic_json()

nlohmann::basic_json::~basic_json ( )
inlinenoexcept

destructor

See also
https://json.nlohmann.me/api/basic_json/~basic_json/

Definition at line 18407 of file json.hpp.

Member Function Documentation

◆ accept() [1/3]

static JSON_HEDLEY_WARN_UNUSED_RESULT bool nlohmann::basic_json::accept ( detail::span_input_adapter &&  i,
const bool  ignore_comments = false 
)
inlinestatic

Definition at line 20871 of file json.hpp.

◆ accept() [2/3]

template<typename InputType >
static bool nlohmann::basic_json::accept ( InputType &&  i,
const bool  ignore_comments = false 
)
inlinestatic

check if the input is valid JSON

See also
https://json.nlohmann.me/api/basic_json/accept/

Definition at line 20854 of file json.hpp.

◆ accept() [3/3]

template<typename IteratorType >
static bool nlohmann::basic_json::accept ( IteratorType  first,
IteratorType  last,
const bool  ignore_comments = false 
)
inlinestatic

check if the input is valid JSON

See also
https://json.nlohmann.me/api/basic_json/accept/

Definition at line 20863 of file json.hpp.

◆ array()

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::array ( initializer_list_t  init = {})
inlinestatic

explicitly create an array from an initializer list

See also
https://json.nlohmann.me/api/basic_json/array/

Definition at line 18159 of file json.hpp.

◆ assert_invariant()

void nlohmann::basic_json::assert_invariant ( bool  check_parents = true) const
inlineprivatenoexcept

checks the class invariants

This function asserts the class invariants. It needs to be called at the end of every constructor to make sure that created objects respect the invariant. Furthermore, it has to be called each time the type of a JSON value is changed, because the invariant expresses a relationship between m_type and m_value.

Furthermore, the parent relation is checked for arrays and objects: If check_parents true and the value is an array or object, then the container's elements must have the current value as parent.

Parameters
[in]check_parentswhether the parent relation should be checked. The value is true by default and should only be set to false during destruction of objects when the invariant does not need to hold.

Definition at line 17840 of file json.hpp.

◆ at() [1/6]

reference nlohmann::basic_json::at ( const json_pointer ptr)
inline

access specified element via JSON Pointer

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 21349 of file json.hpp.

◆ at() [2/6]

const_reference nlohmann::basic_json::at ( const json_pointer ptr) const
inline

access specified element via JSON Pointer

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 21356 of file json.hpp.

◆ at() [3/6]

reference nlohmann::basic_json::at ( const typename object_t::key_type &  key)
inline

access specified object element with bounds checking

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 19136 of file json.hpp.

◆ at() [4/6]

const_reference nlohmann::basic_json::at ( const typename object_t::key_type &  key) const
inline

access specified object element with bounds checking

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 19159 of file json.hpp.

◆ at() [5/6]

reference nlohmann::basic_json::at ( size_type  idx)
inline

access specified array element with bounds checking

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 19090 of file json.hpp.

◆ at() [6/6]

const_reference nlohmann::basic_json::at ( size_type  idx) const
inline

access specified array element with bounds checking

See also
https://json.nlohmann.me/api/basic_json/at/

Definition at line 19113 of file json.hpp.

◆ back() [1/2]

reference nlohmann::basic_json::back ( )
inline

access the last element

See also
https://json.nlohmann.me/api/basic_json/back/

Definition at line 19393 of file json.hpp.

◆ back() [2/2]

const_reference nlohmann::basic_json::back ( ) const
inline

access the last element

See also
https://json.nlohmann.me/api/basic_json/back/

Definition at line 19402 of file json.hpp.

◆ begin() [1/2]

const_iterator nlohmann::basic_json::begin ( ) const
inlinenoexcept

returns an iterator to the first element

See also
https://json.nlohmann.me/api/basic_json/begin/

Definition at line 19673 of file json.hpp.

◆ begin() [2/2]

iterator nlohmann::basic_json::begin ( )
inlinenoexcept

returns an iterator to the first element

See also
https://json.nlohmann.me/api/basic_json/begin/

Definition at line 19664 of file json.hpp.

◆ binary() [1/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::binary ( const typename binary_t::container_type init)
inlinestatic

explicitly create a binary array (without subtype)

See also
https://json.nlohmann.me/api/basic_json/binary/

Definition at line 18115 of file json.hpp.

◆ binary() [2/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::binary ( const typename binary_t::container_type init,
typename binary_t::subtype_type  subtype 
)
inlinestatic

explicitly create a binary array (with subtype)

See also
https://json.nlohmann.me/api/basic_json/binary/

Definition at line 18126 of file json.hpp.

◆ binary() [3/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::binary ( typename binary_t::container_type &&  init)
inlinestatic

explicitly create a binary array

See also
https://json.nlohmann.me/api/basic_json/binary/

Definition at line 18137 of file json.hpp.

◆ binary() [4/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::binary ( typename binary_t::container_type &&  init,
typename binary_t::subtype_type  subtype 
)
inlinestatic

explicitly create a binary array (with subtype)

See also
https://json.nlohmann.me/api/basic_json/binary/

Definition at line 18148 of file json.hpp.

◆ cbegin()

const_iterator nlohmann::basic_json::cbegin ( ) const
inlinenoexcept

returns a const iterator to the first element

See also
https://json.nlohmann.me/api/basic_json/cbegin/

Definition at line 19680 of file json.hpp.

◆ cend()

const_iterator nlohmann::basic_json::cend ( ) const
inlinenoexcept

returns an iterator to one past the last element

See also
https://json.nlohmann.me/api/basic_json/cend/

Definition at line 19705 of file json.hpp.

◆ clear()

void nlohmann::basic_json::clear ( )
inlinenoexcept

clears the contents

See also
https://json.nlohmann.me/api/basic_json/clear/

Definition at line 19925 of file json.hpp.

◆ contains() [1/2]

bool nlohmann::basic_json::contains ( const json_pointer ptr) const
inline

check the existence of an element in a JSON object given a JSON pointer

See also
https://json.nlohmann.me/api/basic_json/contains/

Definition at line 19647 of file json.hpp.

◆ contains() [2/2]

template<typename KeyT , typename std::enable_if< !std::is_same< typename std::decay< KeyT >::type, json_pointer >::value, int >::type = 0>
bool nlohmann::basic_json::contains ( KeyT &&  key) const
inline

check the existence of an element in a JSON object

See also
https://json.nlohmann.me/api/basic_json/contains/

Definition at line 19640 of file json.hpp.

◆ count()

template<typename KeyT >
size_type nlohmann::basic_json::count ( KeyT &&  key) const
inline

returns the number of occurrences of a key in a JSON object

See also
https://json.nlohmann.me/api/basic_json/count/

Definition at line 19630 of file json.hpp.

◆ crbegin()

const_reverse_iterator nlohmann::basic_json::crbegin ( ) const
inlinenoexcept

returns a const reverse iterator to the last element

See also
https://json.nlohmann.me/api/basic_json/crbegin/

Definition at line 19742 of file json.hpp.

◆ create()

template<typename T , typename... Args>
static JSON_HEDLEY_RETURNS_NON_NULL T* nlohmann::basic_json::create ( Args &&...  args)
inlinestaticprivate

helper for exception-safe object creation

Definition at line 17546 of file json.hpp.

◆ crend()

const_reverse_iterator nlohmann::basic_json::crend ( ) const
inlinenoexcept

returns a const reverse iterator to one before the first

See also
https://json.nlohmann.me/api/basic_json/crend/

Definition at line 19749 of file json.hpp.

◆ destroy()

void nlohmann::basic_json::destroy ( value_t  t)
inlineprivate

Definition at line 17722 of file json.hpp.

◆ diff()

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::diff ( const basic_json source,
const basic_json target,
const std::string &  path = "" 
)
inlinestatic

creates a diff as a JSON patch

See also
https://json.nlohmann.me/api/basic_json/diff/

Definition at line 21663 of file json.hpp.

◆ dump()

string_t nlohmann::basic_json::dump ( const int  indent = -1,
const char  indent_char = ' ',
const bool  ensure_ascii = false,
const error_handler_t  error_handler = error_handler_t::strict 
) const
inline

serialization

See also
https://json.nlohmann.me/api/basic_json/dump/

Definition at line 18426 of file json.hpp.

◆ emplace()

template<class... Args>
std::pair<iterator, bool> nlohmann::basic_json::emplace ( Args &&...  args)
inline

add an object to an object if key does not exist

See also
https://json.nlohmann.me/api/basic_json/emplace/

Definition at line 20132 of file json.hpp.

◆ emplace_back()

template<class... Args>
reference nlohmann::basic_json::emplace_back ( Args &&...  args)
inline

add an object to an array

See also
https://json.nlohmann.me/api/basic_json/emplace_back/

Definition at line 20107 of file json.hpp.

◆ empty()

bool nlohmann::basic_json::empty ( ) const
inlinenoexcept

checks whether the container is empty.

See also
https://json.nlohmann.me/api/basic_json/empty/

Definition at line 19803 of file json.hpp.

◆ end() [1/2]

const_iterator nlohmann::basic_json::end ( ) const
inlinenoexcept

returns an iterator to one past the last element

See also
https://json.nlohmann.me/api/basic_json/end/

Definition at line 19698 of file json.hpp.

◆ end() [2/2]

iterator nlohmann::basic_json::end ( )
inlinenoexcept

returns an iterator to one past the last element

See also
https://json.nlohmann.me/api/basic_json/end/

Definition at line 19689 of file json.hpp.

◆ erase() [1/4]

void nlohmann::basic_json::erase ( const size_type  idx)
inline

remove element from a JSON array given an index

See also
https://json.nlohmann.me/api/basic_json/erase/

Definition at line 19569 of file json.hpp.

◆ erase() [2/4]

size_type nlohmann::basic_json::erase ( const typename object_t::key_type &  key)
inline

remove element from a JSON object given a key

See also
https://json.nlohmann.me/api/basic_json/erase/

Definition at line 19556 of file json.hpp.

◆ erase() [3/4]

template<class IteratorType , typename std::enable_if< std::is_same< IteratorType, typename basic_json_t::iterator >::value||std::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int >::type = 0>
IteratorType nlohmann::basic_json::erase ( IteratorType  first,
IteratorType  last 
)
inline

remove elements given an iterator range

See also
https://json.nlohmann.me/api/basic_json/erase/

Definition at line 19486 of file json.hpp.

◆ erase() [4/4]

template<class IteratorType , typename std::enable_if< std::is_same< IteratorType, typename basic_json_t::iterator >::value||std::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int >::type = 0>
IteratorType nlohmann::basic_json::erase ( IteratorType  pos)
inline

remove element given an iterator

See also
https://json.nlohmann.me/api/basic_json/erase/

Definition at line 19415 of file json.hpp.

◆ find() [1/2]

template<typename KeyT >
iterator nlohmann::basic_json::find ( KeyT &&  key)
inline

find an element in a JSON object

See also
https://json.nlohmann.me/api/basic_json/find/

Definition at line 19600 of file json.hpp.

◆ find() [2/2]

template<typename KeyT >
const_iterator nlohmann::basic_json::find ( KeyT &&  key) const
inline

find an element in a JSON object

See also
https://json.nlohmann.me/api/basic_json/find/

Definition at line 19615 of file json.hpp.

◆ flatten()

basic_json nlohmann::basic_json::flatten ( ) const
inline

return flattened JSON value

See also
https://json.nlohmann.me/api/basic_json/flatten/

Definition at line 21363 of file json.hpp.

◆ from_bson() [1/4]

template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_bson ( const T *  ptr,
std::size_t  len,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21304 of file json.hpp.

◆ from_bson() [2/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_bson ( detail::span_input_adapter &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21313 of file json.hpp.

◆ from_bson() [3/4]

template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_bson ( InputType &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in BSON format

See also
https://json.nlohmann.me/api/basic_json/from_bson/

Definition at line 21275 of file json.hpp.

◆ from_bson() [4/4]

template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_bson ( IteratorType  first,
IteratorType  last,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in BSON format

See also
https://json.nlohmann.me/api/basic_json/from_bson/

Definition at line 21290 of file json.hpp.

◆ from_cbor() [1/4]

template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_cbor ( const T *  ptr,
std::size_t  len,
const bool  strict = true,
const bool  allow_exceptions = true,
const cbor_tag_handler_t  tag_handler = cbor_tag_handler_t::error 
)
inlinestatic

Definition at line 21139 of file json.hpp.

◆ from_cbor() [2/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_cbor ( detail::span_input_adapter &&  i,
const bool  strict = true,
const bool  allow_exceptions = true,
const cbor_tag_handler_t  tag_handler = cbor_tag_handler_t::error 
)
inlinestatic

Definition at line 21150 of file json.hpp.

◆ from_cbor() [3/4]

template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_cbor ( InputType &&  i,
const bool  strict = true,
const bool  allow_exceptions = true,
const cbor_tag_handler_t  tag_handler = cbor_tag_handler_t::error 
)
inlinestatic

create a JSON value from an input in CBOR format

See also
https://json.nlohmann.me/api/basic_json/from_cbor/

Definition at line 21108 of file json.hpp.

◆ from_cbor() [4/4]

template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_cbor ( IteratorType  first,
IteratorType  last,
const bool  strict = true,
const bool  allow_exceptions = true,
const cbor_tag_handler_t  tag_handler = cbor_tag_handler_t::error 
)
inlinestatic

create a JSON value from an input in CBOR format

See also
https://json.nlohmann.me/api/basic_json/from_cbor/

Definition at line 21124 of file json.hpp.

◆ from_msgpack() [1/4]

template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_msgpack ( const T *  ptr,
std::size_t  len,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21196 of file json.hpp.

◆ from_msgpack() [2/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_msgpack ( detail::span_input_adapter &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21205 of file json.hpp.

◆ from_msgpack() [3/4]

template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_msgpack ( InputType &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in MessagePack format

See also
https://json.nlohmann.me/api/basic_json/from_msgpack/

Definition at line 21167 of file json.hpp.

◆ from_msgpack() [4/4]

template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_msgpack ( IteratorType  first,
IteratorType  last,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in MessagePack format

See also
https://json.nlohmann.me/api/basic_json/from_msgpack/

Definition at line 21182 of file json.hpp.

◆ from_ubjson() [1/4]

template<typename T >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_ubjson ( const T *  ptr,
std::size_t  len,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21250 of file json.hpp.

◆ from_ubjson() [2/4]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_ubjson ( detail::span_input_adapter &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

Definition at line 21259 of file json.hpp.

◆ from_ubjson() [3/4]

template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_ubjson ( InputType &&  i,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in UBJSON format

See also
https://json.nlohmann.me/api/basic_json/from_ubjson/

Definition at line 21221 of file json.hpp.

◆ from_ubjson() [4/4]

template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::from_ubjson ( IteratorType  first,
IteratorType  last,
const bool  strict = true,
const bool  allow_exceptions = true 
)
inlinestatic

create a JSON value from an input in UBJSON format

See also
https://json.nlohmann.me/api/basic_json/from_ubjson/

Definition at line 21236 of file json.hpp.

◆ front() [1/2]

reference nlohmann::basic_json::front ( )
inline

access the first element

See also
https://json.nlohmann.me/api/basic_json/front/

Definition at line 19379 of file json.hpp.

◆ front() [2/2]

const_reference nlohmann::basic_json::front ( ) const
inline

access the first element

See also
https://json.nlohmann.me/api/basic_json/front/

Definition at line 19386 of file json.hpp.

◆ get() [1/2]

template<typename ValueTypeCV , typename ValueType = detail::uncvref_t<ValueTypeCV>>
auto nlohmann::basic_json::get ( ) const -> decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4>
inlinenoexcept

get a (pointer) value (explicit)

Performs explicit type conversion between the JSON value and a compatible value if required.

Template Parameters
ValueTypeCVthe provided value type
ValueTypethe returned value type
Returns
copy of the JSON value, converted to
Template Parameters
ValueTypeif necessary
Exceptions
whatjson_serializer<ValueType> from_json() method throws if conversion is required
Since
version 2.1.0

Definition at line 18898 of file json.hpp.

◆ get() [2/2]

template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0>
auto nlohmann::basic_json::get ( ) -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
inlinenoexcept

get a pointer value (explicit)

Explicit pointer access to the internally stored JSON value. No copies are made.

Warning
The pointer becomes invalid if the underlying JSON object changes.
Template Parameters
PointerTypepointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, number_unsigned_t, or number_float_t.
Returns
pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise

@complexity Constant.

@liveexample{The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.,get__PointerType}

See also
see get_ptr() for explicit pointer-member access
Since
version 1.0.0

Definition at line 18939 of file json.hpp.

◆ get_allocator()

static allocator_type nlohmann::basic_json::get_allocator ( )
inlinestatic

returns the allocator associated with the container

See also
https://json.nlohmann.me/api/basic_json/get_allocator/

Definition at line 17420 of file json.hpp.

◆ get_binary() [1/2]

binary_t& nlohmann::basic_json::get_binary ( )
inline

get a binary value

See also
https://json.nlohmann.me/api/basic_json/get_binary/

Definition at line 19055 of file json.hpp.

◆ get_binary() [2/2]

const binary_t& nlohmann::basic_json::get_binary ( ) const
inline

get a binary value

See also
https://json.nlohmann.me/api/basic_json/get_binary/

Definition at line 19067 of file json.hpp.

◆ get_impl() [1/7]

boolean_t nlohmann::basic_json::get_impl ( boolean_t ) const
inlineprivate

get a boolean (explicit)

Definition at line 18559 of file json.hpp.

◆ get_impl() [2/7]

template<typename ValueType , detail::enable_if_t< detail::is_default_constructible< ValueType >::value &&detail::has_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType nlohmann::basic_json::get_impl ( detail::priority_tag< 0 >  ) const
inlineprivatenoexcept

get a value (explicit)

Explicit type conversion between the JSON value and a compatible value which is CopyConstructible and DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

ValueType ret;
return ret;

This overloads is chosen if:

Template Parameters
ValueTypethe returned value type
Returns
copy of the JSON value, converted to ValueType
Exceptions
whatjson_serializer<ValueType> from_json() method throws

@liveexample{The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers\, (2) A JSON array can be converted to a standard std::vector<short>\, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string\, json>.,get__ValueType_const}

Since
version 2.1.0

Definition at line 18760 of file json.hpp.

◆ get_impl() [3/7]

template<typename ValueType , detail::enable_if_t< detail::has_non_default_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType nlohmann::basic_json::get_impl ( detail::priority_tag< 1 >  ) const
inlineprivatenoexcept

get a value (explicit); special case

Explicit type conversion between the JSON value and a compatible value which is not CopyConstructible and not DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

This overloads is chosen if:

Note
If json_serializer<ValueType> has both overloads of from_json(), this one is chosen.
Template Parameters
ValueTypethe returned value type
Returns
copy of the JSON value, converted to ValueType
Exceptions
whatjson_serializer<ValueType> from_json() method throws
Since
version 2.1.0

Definition at line 18802 of file json.hpp.

◆ get_impl() [4/7]

template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0>
BasicJsonType nlohmann::basic_json::get_impl ( detail::priority_tag< 2 >  ) const
inlineprivate

get special-case overload

This overloads converts the current basic_json in a different basic_json type

Template Parameters
BasicJsonType== basic_json
Returns
a copy of *this, converted into BasicJsonType

@complexity Depending on the implementation of the called from_json() method.

Since
version 3.2.0

Definition at line 18827 of file json.hpp.

◆ get_impl() [5/7]

template<typename BasicJsonType , detail::enable_if_t< std::is_same< BasicJsonType, basic_json_t >::value, int > = 0>
basic_json nlohmann::basic_json::get_impl ( detail::priority_tag< 3 >  ) const
inlineprivate

get special-case overload

This overloads avoids a lot of template boilerplate, it can be seen as the identity method

Template Parameters
BasicJsonType== basic_json
Returns
a copy of *this

@complexity Constant.

Since
version 2.1.0

Definition at line 18850 of file json.hpp.

◆ get_impl() [6/7]

return nlohmann::basic_json::get_impl ( detail::priority_tag< 4 > {}  )

◆ get_impl() [7/7]

template<typename PointerType , detail::enable_if_t< std::is_pointer< PointerType >::value, int > = 0>
constexpr auto nlohmann::basic_json::get_impl ( detail::priority_tag< 4 >  ) const -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
inlineconstexprprivatenoexcept

get a pointer value (explicit)

get a pointer value (explicit) Explicit pointer access to the internally stored JSON value. No copies are made.

Warning
The pointer becomes invalid if the underlying JSON object changes.
Template Parameters
PointerTypepointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, number_unsigned_t, or number_float_t.
Returns
pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise

@complexity Constant.

@liveexample{The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.,get__PointerType}

See also
see get_ptr() for explicit pointer-member access
Since
version 1.0.0

Definition at line 18863 of file json.hpp.

◆ get_impl_ptr() [1/16]

array_t* nlohmann::basic_json::get_impl_ptr ( array_t )
inlineprivatenoexcept

get a pointer to the value (array)

Definition at line 18582 of file json.hpp.

◆ get_impl_ptr() [2/16]

binary_t* nlohmann::basic_json::get_impl_ptr ( binary_t )
inlineprivatenoexcept

get a pointer to the value (binary)

Definition at line 18654 of file json.hpp.

◆ get_impl_ptr() [3/16]

boolean_t* nlohmann::basic_json::get_impl_ptr ( boolean_t )
inlineprivatenoexcept

get a pointer to the value (boolean)

Definition at line 18606 of file json.hpp.

◆ get_impl_ptr() [4/16]

constexpr const array_t* nlohmann::basic_json::get_impl_ptr ( const array_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (array)

Definition at line 18588 of file json.hpp.

◆ get_impl_ptr() [5/16]

constexpr const binary_t* nlohmann::basic_json::get_impl_ptr ( const binary_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (binary)

Definition at line 18660 of file json.hpp.

◆ get_impl_ptr() [6/16]

constexpr const boolean_t* nlohmann::basic_json::get_impl_ptr ( const boolean_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (boolean)

Definition at line 18612 of file json.hpp.

◆ get_impl_ptr() [7/16]

constexpr const number_float_t* nlohmann::basic_json::get_impl_ptr ( const number_float_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (floating-point number)

Definition at line 18648 of file json.hpp.

◆ get_impl_ptr() [8/16]

constexpr const number_integer_t* nlohmann::basic_json::get_impl_ptr ( const number_integer_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (integer number)

Definition at line 18624 of file json.hpp.

◆ get_impl_ptr() [9/16]

constexpr const number_unsigned_t* nlohmann::basic_json::get_impl_ptr ( const number_unsigned_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (unsigned number)

Definition at line 18636 of file json.hpp.

◆ get_impl_ptr() [10/16]

constexpr const object_t* nlohmann::basic_json::get_impl_ptr ( const object_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (object)

Definition at line 18576 of file json.hpp.

◆ get_impl_ptr() [11/16]

constexpr const string_t* nlohmann::basic_json::get_impl_ptr ( const string_t ) const
inlineconstexprprivatenoexcept

get a pointer to the value (string)

Definition at line 18600 of file json.hpp.

◆ get_impl_ptr() [12/16]

number_float_t* nlohmann::basic_json::get_impl_ptr ( number_float_t )
inlineprivatenoexcept

get a pointer to the value (floating-point number)

Definition at line 18642 of file json.hpp.

◆ get_impl_ptr() [13/16]

number_integer_t* nlohmann::basic_json::get_impl_ptr ( number_integer_t )
inlineprivatenoexcept

get a pointer to the value (integer number)

Definition at line 18618 of file json.hpp.

◆ get_impl_ptr() [14/16]

number_unsigned_t* nlohmann::basic_json::get_impl_ptr ( number_unsigned_t )
inlineprivatenoexcept

get a pointer to the value (unsigned number)

Definition at line 18630 of file json.hpp.

◆ get_impl_ptr() [15/16]

object_t* nlohmann::basic_json::get_impl_ptr ( object_t )
inlineprivatenoexcept

get a pointer to the value (object)

Definition at line 18570 of file json.hpp.

◆ get_impl_ptr() [16/16]

string_t* nlohmann::basic_json::get_impl_ptr ( string_t )
inlineprivatenoexcept

get a pointer to the value (string)

Definition at line 18594 of file json.hpp.

◆ get_ptr() [1/2]

template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value &&std::is_const< typename std::remove_pointer< PointerType >::type >::value, int >::type = 0>
constexpr auto nlohmann::basic_json::get_ptr ( ) const -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
inlineconstexprnoexcept

get a pointer value (implicit)

See also
https://json.nlohmann.me/api/basic_json/get_ptr/

Definition at line 18710 of file json.hpp.

◆ get_ptr() [2/2]

template<typename PointerType , typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0>
auto nlohmann::basic_json::get_ptr ( ) -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
inlinenoexcept

get a pointer value (implicit)

See also
https://json.nlohmann.me/api/basic_json/get_ptr/

Definition at line 18699 of file json.hpp.

◆ get_ref() [1/2]

template<typename ReferenceType , typename std::enable_if< std::is_reference< ReferenceType >::value, int >::type = 0>
ReferenceType nlohmann::basic_json::get_ref ( )
inline

get a reference value (implicit)

See also
https://json.nlohmann.me/api/basic_json/get_ref/

Definition at line 18988 of file json.hpp.

◆ get_ref() [2/2]

template<typename ReferenceType , typename std::enable_if< std::is_reference< ReferenceType >::value &&std::is_const< typename std::remove_reference< ReferenceType >::type >::value, int >::type = 0>
ReferenceType nlohmann::basic_json::get_ref ( ) const
inline

get a reference value (implicit)

See also
https://json.nlohmann.me/api/basic_json/get_ref/

Definition at line 18999 of file json.hpp.

◆ get_ref_impl()

template<typename ReferenceType , typename ThisType >
static ReferenceType nlohmann::basic_json::get_ref_impl ( ThisType &  obj)
inlinestaticprivate

helper function to implement get_ref()

This function helps to implement get_ref() without code duplication for const and non-const overloads

Template Parameters
ThisTypewill be deduced as basic_json or const basic_json
Exceptions
type_error.303if ReferenceType does not match underlying value type of the current JSON

Definition at line 18677 of file json.hpp.

◆ get_to() [1/3]

template<typename T , std::size_t N, typename Array = T (&)[N], detail::enable_if_t< detail::has_from_json< basic_json_t, Array >::value, int > = 0>
Array nlohmann::basic_json::get_to ( T(&)  v[N]) const
inlinenoexcept

Definition at line 18976 of file json.hpp.

◆ get_to() [2/3]

template<typename ValueType , detail::enable_if_t< detail::is_basic_json< ValueType >::value, int > = 0>
ValueType& nlohmann::basic_json::get_to ( ValueType &  v) const
inline

Definition at line 18965 of file json.hpp.

◆ get_to() [3/3]

template<typename ValueType , detail::enable_if_t< !detail::is_basic_json< ValueType >::value &&detail::has_from_json< basic_json_t, ValueType >::value, int > = 0>
ValueType& nlohmann::basic_json::get_to ( ValueType &  v) const
inlinenoexcept

get a value (explicit)

See also
https://json.nlohmann.me/api/basic_json/get_to/

Definition at line 18952 of file json.hpp.

◆ insert() [1/6]

void nlohmann::basic_json::insert ( const_iterator  first,
const_iterator  last 
)
inline

inserts range of elements into object

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20281 of file json.hpp.

◆ insert() [2/6]

iterator nlohmann::basic_json::insert ( const_iterator  pos,
basic_json &&  val 
)
inline

inserts element into array

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20203 of file json.hpp.

◆ insert() [3/6]

iterator nlohmann::basic_json::insert ( const_iterator  pos,
const basic_json val 
)
inline

inserts element into array

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20183 of file json.hpp.

◆ insert() [4/6]

iterator nlohmann::basic_json::insert ( const_iterator  pos,
const_iterator  first,
const_iterator  last 
)
inline

inserts range of elements into array

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20230 of file json.hpp.

◆ insert() [5/6]

iterator nlohmann::basic_json::insert ( const_iterator  pos,
initializer_list_t  ilist 
)
inline

inserts elements from initializer list into array

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20261 of file json.hpp.

◆ insert() [6/6]

iterator nlohmann::basic_json::insert ( const_iterator  pos,
size_type  cnt,
const basic_json val 
)
inline

inserts copies of element into array

See also
https://json.nlohmann.me/api/basic_json/insert/

Definition at line 20210 of file json.hpp.

◆ insert_iterator()

template<typename... Args>
iterator nlohmann::basic_json::insert_iterator ( const_iterator  pos,
Args &&...  args 
)
inline

Helper for insertion of an iterator

Note
: This uses std::distance to support GCC 4.8, see https://github.com/nlohmann/json/pull/1257

Definition at line 20164 of file json.hpp.

◆ is_array()

constexpr bool nlohmann::basic_json::is_array ( ) const
inlineconstexprnoexcept

return whether value is an array

See also
https://json.nlohmann.me/api/basic_json/is_array/

Definition at line 18518 of file json.hpp.

◆ is_binary()

constexpr bool nlohmann::basic_json::is_binary ( ) const
inlineconstexprnoexcept

return whether value is a binary array

See also
https://json.nlohmann.me/api/basic_json/is_binary/

Definition at line 18532 of file json.hpp.

◆ is_boolean()

constexpr bool nlohmann::basic_json::is_boolean ( ) const
inlineconstexprnoexcept

return whether value is a boolean

See also
https://json.nlohmann.me/api/basic_json/is_boolean/

Definition at line 18476 of file json.hpp.

◆ is_discarded()

constexpr bool nlohmann::basic_json::is_discarded ( ) const
inlineconstexprnoexcept

return whether value is discarded

See also
https://json.nlohmann.me/api/basic_json/is_discarded/

Definition at line 18539 of file json.hpp.

◆ is_null()

constexpr bool nlohmann::basic_json::is_null ( ) const
inlineconstexprnoexcept

return whether value is null

See also
https://json.nlohmann.me/api/basic_json/is_null/

Definition at line 18469 of file json.hpp.

◆ is_number()

constexpr bool nlohmann::basic_json::is_number ( ) const
inlineconstexprnoexcept

return whether value is a number

See also
https://json.nlohmann.me/api/basic_json/is_number/

Definition at line 18483 of file json.hpp.

◆ is_number_float()

constexpr bool nlohmann::basic_json::is_number_float ( ) const
inlineconstexprnoexcept

return whether value is a floating-point number

See also
https://json.nlohmann.me/api/basic_json/is_number_float/

Definition at line 18504 of file json.hpp.

◆ is_number_integer()

constexpr bool nlohmann::basic_json::is_number_integer ( ) const
inlineconstexprnoexcept

return whether value is an integer number

See also
https://json.nlohmann.me/api/basic_json/is_number_integer/

Definition at line 18490 of file json.hpp.

◆ is_number_unsigned()

constexpr bool nlohmann::basic_json::is_number_unsigned ( ) const
inlineconstexprnoexcept

return whether value is an unsigned integer number

See also
https://json.nlohmann.me/api/basic_json/is_number_unsigned/

Definition at line 18497 of file json.hpp.

◆ is_object()

constexpr bool nlohmann::basic_json::is_object ( ) const
inlineconstexprnoexcept

return whether value is an object

See also
https://json.nlohmann.me/api/basic_json/is_object/

Definition at line 18511 of file json.hpp.

◆ is_primitive()

constexpr bool nlohmann::basic_json::is_primitive ( ) const
inlineconstexprnoexcept

return whether type is primitive

See also
https://json.nlohmann.me/api/basic_json/is_primitive/

Definition at line 18455 of file json.hpp.

◆ is_string()

constexpr bool nlohmann::basic_json::is_string ( ) const
inlineconstexprnoexcept

return whether value is a string

See also
https://json.nlohmann.me/api/basic_json/is_string/

Definition at line 18525 of file json.hpp.

◆ is_structured()

constexpr bool nlohmann::basic_json::is_structured ( ) const
inlineconstexprnoexcept

return whether type is structured

See also
https://json.nlohmann.me/api/basic_json/is_structured/

Definition at line 18462 of file json.hpp.

◆ items() [1/2]

iteration_proxy<const_iterator> nlohmann::basic_json::items ( ) const
inlinenoexcept

helper to access iterator member functions in range-based for

See also
https://json.nlohmann.me/api/basic_json/items/

Definition at line 19786 of file json.hpp.

◆ items() [2/2]

iteration_proxy<iterator> nlohmann::basic_json::items ( )
inlinenoexcept

helper to access iterator member functions in range-based for

See also
https://json.nlohmann.me/api/basic_json/items/

Definition at line 19779 of file json.hpp.

◆ iterator_wrapper() [1/2]

static iteration_proxy<const_iterator> nlohmann::basic_json::iterator_wrapper ( const_reference  ref)
inlinestaticnoexcept

wrapper to access iterator member functions in range-based for

See also
https://json.nlohmann.me/api/basic_json/items/
Deprecated:
This function is deprecated since 3.1.0 and will be removed in version 4.0.0 of the library. Please use items() instead; that is, replace json::iterator_wrapper(j) with j.items().

Definition at line 19772 of file json.hpp.

◆ iterator_wrapper() [2/2]

static iteration_proxy<iterator> nlohmann::basic_json::iterator_wrapper ( reference  ref)
inlinestaticnoexcept

wrapper to access iterator member functions in range-based for

See also
https://json.nlohmann.me/api/basic_json/items/
Deprecated:
This function is deprecated since 3.1.0 and will be removed in version 4.0.0 of the library. Please use items() instead; that is, replace json::iterator_wrapper(j) with j.items().

Definition at line 19761 of file json.hpp.

◆ json_value() [1/16]

nlohmann::basic_json::json_value ( )
privatedefault

default constructor (for null values)

◆ json_value() [2/16]

nlohmann::basic_json::json_value ( array_t &&  value)
inlineprivate

constructor for rvalue arrays

Definition at line 17708 of file json.hpp.

◆ json_value() [3/16]

nlohmann::basic_json::json_value ( binary_t &&  value)
inlineprivate

constructor for rvalue binary arrays (internal type)

Definition at line 17720 of file json.hpp.

◆ json_value() [4/16]

nlohmann::basic_json::json_value ( boolean_t  v)
inlineprivatenoexcept

constructor for booleans

Definition at line 17613 of file json.hpp.

◆ json_value() [5/16]

nlohmann::basic_json::json_value ( const array_t value)
inlineprivate

constructor for arrays

Definition at line 17705 of file json.hpp.

◆ json_value() [6/16]

nlohmann::basic_json::json_value ( const binary_t value)
inlineprivate

constructor for binary arrays (internal type)

Definition at line 17717 of file json.hpp.

◆ json_value() [7/16]

nlohmann::basic_json::json_value ( const object_t value)
inlineprivate

constructor for objects

Definition at line 17699 of file json.hpp.

◆ json_value() [8/16]

nlohmann::basic_json::json_value ( const string_t value)
inlineprivate

constructor for strings

Definition at line 17693 of file json.hpp.

◆ json_value() [9/16]

nlohmann::basic_json::json_value ( const typename binary_t::container_type value)
inlineprivate

constructor for binary arrays

Definition at line 17711 of file json.hpp.

◆ json_value() [10/16]

nlohmann::basic_json::json_value ( number_float_t  v)
inlineprivatenoexcept

constructor for numbers (floating-point)

Definition at line 17619 of file json.hpp.

◆ json_value() [11/16]

nlohmann::basic_json::json_value ( number_integer_t  v)
inlineprivatenoexcept

constructor for numbers (integer)

Definition at line 17615 of file json.hpp.

◆ json_value() [12/16]

nlohmann::basic_json::json_value ( number_unsigned_t  v)
inlineprivatenoexcept

constructor for numbers (unsigned)

Definition at line 17617 of file json.hpp.

◆ json_value() [13/16]

nlohmann::basic_json::json_value ( object_t &&  value)
inlineprivate

constructor for rvalue objects

Definition at line 17702 of file json.hpp.

◆ json_value() [14/16]

nlohmann::basic_json::json_value ( string_t &&  value)
inlineprivate

constructor for rvalue strings

Definition at line 17696 of file json.hpp.

◆ json_value() [15/16]

nlohmann::basic_json::json_value ( typename binary_t::container_type &&  value)
inlineprivate

constructor for rvalue binary arrays

Definition at line 17714 of file json.hpp.

◆ json_value() [16/16]

nlohmann::basic_json::json_value ( value_t  t)
inlineprivate

constructor for empty values of a given type

Definition at line 17621 of file json.hpp.

◆ max_size()

size_type nlohmann::basic_json::max_size ( ) const
inlinenoexcept

returns the maximum possible number of elements

See also
https://json.nlohmann.me/api/basic_json/max_size/

Definition at line 19881 of file json.hpp.

◆ merge_patch()

void nlohmann::basic_json::merge_patch ( const basic_json apply_patch)
inline

applies a JSON Merge Patch

See also
https://json.nlohmann.me/api/basic_json/merge_patch/

Definition at line 21806 of file json.hpp.

◆ meta()

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::meta ( )
inlinestatic

returns version information on the library

See also
https://json.nlohmann.me/api/basic_json/meta/

Definition at line 17428 of file json.hpp.

◆ object()

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::object ( initializer_list_t  init = {})
inlinestatic

explicitly create an object from an initializer list

See also
https://json.nlohmann.me/api/basic_json/object/

Definition at line 18167 of file json.hpp.

◆ operator value_t()

constexpr nlohmann::basic_json::operator value_t ( ) const
inlineconstexprnoexcept

return the type of the JSON value (implicit)

See also
https://json.nlohmann.me/api/basic_json/operator_value_t/

Definition at line 18546 of file json.hpp.

◆ operator ValueType()

template<typename ValueType , typename std::enable_if< detail::conjunction< detail::negation< std::is_pointer< ValueType >>, detail::negation< std::is_same< ValueType, detail::json_ref< basic_json >>>, detail::negation< std::is_same< ValueType, typename string_t::value_type >>, detail::negation< detail::is_basic_json< ValueType >>, detail::negation< std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>>, detail::is_detected_lazy< detail::get_template_function, const basic_json_t &, ValueType > >::value, int >::type = 0>
JSON_EXPLICIT nlohmann::basic_json::operator ValueType ( ) const
inline

get a value (implicit)

Implicit type conversion between the JSON value and a compatible value. The call is realized by calling get() const.

Template Parameters
ValueTypenon-pointer type compatible to the JSON value, for instance int for JSON integer numbers, bool for JSON booleans, or std::vector types for JSON arrays. The character type of string_t as well as an initializer list of this type is excluded to avoid ambiguities as these types implicitly convert to std::string.
Returns
copy of the JSON value, converted to type ValueType
Exceptions
type_error.302in case passed type ValueType is incompatible to the JSON value type (e.g., the JSON value is of type boolean, but a string is requested); see example below

@complexity Linear in the size of the JSON value.

@liveexample{The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers\, (2) A JSON array can be converted to a standard std::vector<short>\, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string\, json>.,operator__ValueType}

Since
version 1.0.0

Definition at line 19047 of file json.hpp.

◆ operator+=() [1/4]

reference nlohmann::basic_json::operator+= ( basic_json &&  val)
inline

add an object to an array

See also
https://json.nlohmann.me/api/basic_json/operator+=/

Definition at line 20011 of file json.hpp.

◆ operator+=() [2/4]

reference nlohmann::basic_json::operator+= ( const basic_json val)
inline

add an object to an array

See also
https://json.nlohmann.me/api/basic_json/operator+=/

Definition at line 20043 of file json.hpp.

◆ operator+=() [3/4]

reference nlohmann::basic_json::operator+= ( const typename object_t::value_type &  val)
inline

add an object to an object

See also
https://json.nlohmann.me/api/basic_json/operator+=/

Definition at line 20074 of file json.hpp.

◆ operator+=() [4/4]

reference nlohmann::basic_json::operator+= ( initializer_list_t  init)
inline

add an object to an object

See also
https://json.nlohmann.me/api/basic_json/operator+=/

Definition at line 20098 of file json.hpp.

◆ operator=()

basic_json& nlohmann::basic_json::operator= ( basic_json  other)
inlinenoexcept

copy assignment

See also
https://json.nlohmann.me/api/basic_json/operator=/

Definition at line 18386 of file json.hpp.

◆ operator[]() [1/8]

reference nlohmann::basic_json::operator[] ( const json_pointer ptr)
inline

access specified element via JSON Pointer

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 21335 of file json.hpp.

◆ operator[]() [2/8]

const_reference nlohmann::basic_json::operator[] ( const json_pointer ptr) const
inline

access specified element via JSON Pointer

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 21342 of file json.hpp.

◆ operator[]() [3/8]

reference nlohmann::basic_json::operator[] ( const typename object_t::key_type &  key)
inline

access specified object element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19241 of file json.hpp.

◆ operator[]() [4/8]

const_reference nlohmann::basic_json::operator[] ( const typename object_t::key_type &  key) const
inline

access specified object element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19262 of file json.hpp.

◆ operator[]() [5/8]

reference nlohmann::basic_json::operator[] ( size_type  idx)
inline

access specified array element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19182 of file json.hpp.

◆ operator[]() [6/8]

const_reference nlohmann::basic_json::operator[] ( size_type  idx) const
inline

access specified array element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19228 of file json.hpp.

◆ operator[]() [7/8]

template<typename T >
reference nlohmann::basic_json::operator[] ( T *  key)
inline

access specified object element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19278 of file json.hpp.

◆ operator[]() [8/8]

template<typename T >
const_reference nlohmann::basic_json::operator[] ( T *  key) const
inline

access specified object element

See also
https://json.nlohmann.me/api/basic_json/operator%5B%5D/

Definition at line 19301 of file json.hpp.

◆ parse() [1/3]

static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::parse ( detail::span_input_adapter &&  i,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions = true,
const bool  ignore_comments = false 
)
inlinestatic

Definition at line 20841 of file json.hpp.

◆ parse() [2/3]

template<typename InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::parse ( InputType &&  i,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions = true,
const bool  ignore_comments = false 
)
inlinestatic

deserialize from a compatible input

See also
https://json.nlohmann.me/api/basic_json/parse/

Definition at line 20814 of file json.hpp.

◆ parse() [3/3]

template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json::parse ( IteratorType  first,
IteratorType  last,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions = true,
const bool  ignore_comments = false 
)
inlinestatic

deserialize from a pair of character iterators

See also
https://json.nlohmann.me/api/basic_json/parse/

Definition at line 20828 of file json.hpp.

◆ parser()

template<typename InputAdapterType >
static ::nlohmann::detail::parser<basic_json, InputAdapterType> nlohmann::basic_json::parser ( InputAdapterType  adapter,
detail::parser_callback_t< basic_json cb = nullptr,
const bool  allow_exceptions = true,
const bool  ignore_comments = false 
)
inlineprivate

Definition at line 17310 of file json.hpp.

◆ patch()

basic_json nlohmann::basic_json::patch ( const basic_json json_patch) const
inline

applies a JSON patch

See also
https://json.nlohmann.me/api/basic_json/patch/

Definition at line 21388 of file json.hpp.

◆ push_back() [1/4]

void nlohmann::basic_json::push_back ( basic_json &&  val)
inline

add an object to an array

See also
https://json.nlohmann.me/api/basic_json/push_back/

Definition at line 19986 of file json.hpp.

◆ push_back() [2/4]

void nlohmann::basic_json::push_back ( const basic_json val)
inline

add an object to an array

See also
https://json.nlohmann.me/api/basic_json/push_back/

Definition at line 20019 of file json.hpp.

◆ push_back() [3/4]

void nlohmann::basic_json::push_back ( const typename object_t::value_type &  val)
inline

add an object to an object

See also
https://json.nlohmann.me/api/basic_json/push_back/

Definition at line 20051 of file json.hpp.

◆ push_back() [4/4]

void nlohmann::basic_json::push_back ( initializer_list_t  init)
inline

add an object to an object

See also
https://json.nlohmann.me/api/basic_json/push_back/

Definition at line 20082 of file json.hpp.

◆ rbegin() [1/2]

const_reverse_iterator nlohmann::basic_json::rbegin ( ) const
inlinenoexcept

returns an iterator to the reverse-beginning

See also
https://json.nlohmann.me/api/basic_json/rbegin/

Definition at line 19721 of file json.hpp.

◆ rbegin() [2/2]

reverse_iterator nlohmann::basic_json::rbegin ( )
inlinenoexcept

returns an iterator to the reverse-beginning

See also
https://json.nlohmann.me/api/basic_json/rbegin/

Definition at line 19714 of file json.hpp.

◆ rend() [1/2]

const_reverse_iterator nlohmann::basic_json::rend ( ) const
inlinenoexcept

returns an iterator to the reverse-end

See also
https://json.nlohmann.me/api/basic_json/rend/

Definition at line 19735 of file json.hpp.

◆ rend() [2/2]

reverse_iterator nlohmann::basic_json::rend ( )
inlinenoexcept

returns an iterator to the reverse-end

See also
https://json.nlohmann.me/api/basic_json/rend/

Definition at line 19728 of file json.hpp.

◆ sax_parse() [1/3]

template<typename SAX >
static bool nlohmann::basic_json::sax_parse ( detail::span_input_adapter &&  i,
SAX *  sax,
input_format_t  format = input_format_t::json,
const bool  strict = true,
const bool  ignore_comments = false 
)
inlinestatic

generate SAX events

See also
https://json.nlohmann.me/api/basic_json/sax_parse/
Deprecated:
This function is deprecated since 3.8.0 and will be removed in version 4.0.0 of the library. Please use sax_parse(ptr, ptr + len) instead.

Definition at line 20915 of file json.hpp.

◆ sax_parse() [2/3]

template<typename InputType , typename SAX >
static bool nlohmann::basic_json::sax_parse ( InputType &&  i,
SAX *  sax,
input_format_t  format = input_format_t::json,
const bool  strict = true,
const bool  ignore_comments = false 
)
inlinestatic

generate SAX events

See also
https://json.nlohmann.me/api/basic_json/sax_parse/

Definition at line 20881 of file json.hpp.

◆ sax_parse() [3/3]

template<class IteratorType , class SAX >
static bool nlohmann::basic_json::sax_parse ( IteratorType  first,
IteratorType  last,
SAX *  sax,
input_format_t  format = input_format_t::json,
const bool  strict = true,
const bool  ignore_comments = false 
)
inlinestatic

generate SAX events

See also
https://json.nlohmann.me/api/basic_json/sax_parse/

Definition at line 20896 of file json.hpp.

◆ set_parent()

reference nlohmann::basic_json::set_parent ( reference  j,
std::size_t  old_capacity = static_cast<std::size_t>(-1) 
)
inlineprivate

Definition at line 17911 of file json.hpp.

◆ set_parents() [1/2]

void nlohmann::basic_json::set_parents ( )
inlineprivate

Definition at line 17861 of file json.hpp.

◆ set_parents() [2/2]

iterator nlohmann::basic_json::set_parents ( iterator  it,
typename iterator::difference_type  count_set_parents 
)
inlineprivate

Definition at line 17898 of file json.hpp.

◆ size()

size_type nlohmann::basic_json::size ( ) const
inlinenoexcept

returns the number of elements

See also
https://json.nlohmann.me/api/basic_json/size/

Definition at line 19842 of file json.hpp.

◆ swap() [1/6]

void nlohmann::basic_json::swap ( array_t other)
inline

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20389 of file json.hpp.

◆ swap() [2/6]

void nlohmann::basic_json::swap ( binary_t other)
inline

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20434 of file json.hpp.

◆ swap() [3/6]

void nlohmann::basic_json::swap ( object_t other)
inline

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20404 of file json.hpp.

◆ swap() [4/6]

void nlohmann::basic_json::swap ( reference  other)
inlinenoexcept

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20360 of file json.hpp.

◆ swap() [5/6]

void nlohmann::basic_json::swap ( string_t other)
inline

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20419 of file json.hpp.

◆ swap() [6/6]

void nlohmann::basic_json::swap ( typename binary_t::container_type other)
inline

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20449 of file json.hpp.

◆ to_bson() [1/3]

static std::vector<std::uint8_t> nlohmann::basic_json::to_bson ( const basic_json j)
inlinestatic

create a BSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_bson/

Definition at line 21083 of file json.hpp.

◆ to_bson() [2/3]

static void nlohmann::basic_json::to_bson ( const basic_json j,
detail::output_adapter< char >  o 
)
inlinestatic

create a BSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_bson/

Definition at line 21099 of file json.hpp.

◆ to_bson() [3/3]

static void nlohmann::basic_json::to_bson ( const basic_json j,
detail::output_adapter< std::uint8_t >  o 
)
inlinestatic

create a BSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_bson/

Definition at line 21092 of file json.hpp.

◆ to_cbor() [1/3]

static std::vector<std::uint8_t> nlohmann::basic_json::to_cbor ( const basic_json j)
inlinestatic

create a CBOR serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_cbor/

Definition at line 21010 of file json.hpp.

◆ to_cbor() [2/3]

static void nlohmann::basic_json::to_cbor ( const basic_json j,
detail::output_adapter< char >  o 
)
inlinestatic

create a CBOR serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_cbor/

Definition at line 21026 of file json.hpp.

◆ to_cbor() [3/3]

static void nlohmann::basic_json::to_cbor ( const basic_json j,
detail::output_adapter< std::uint8_t >  o 
)
inlinestatic

create a CBOR serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_cbor/

Definition at line 21019 of file json.hpp.

◆ to_msgpack() [1/3]

static std::vector<std::uint8_t> nlohmann::basic_json::to_msgpack ( const basic_json j)
inlinestatic

create a MessagePack serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_msgpack/

Definition at line 21033 of file json.hpp.

◆ to_msgpack() [2/3]

static void nlohmann::basic_json::to_msgpack ( const basic_json j,
detail::output_adapter< char >  o 
)
inlinestatic

create a MessagePack serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_msgpack/

Definition at line 21049 of file json.hpp.

◆ to_msgpack() [3/3]

static void nlohmann::basic_json::to_msgpack ( const basic_json j,
detail::output_adapter< std::uint8_t >  o 
)
inlinestatic

create a MessagePack serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_msgpack/

Definition at line 21042 of file json.hpp.

◆ to_ubjson() [1/3]

static std::vector<std::uint8_t> nlohmann::basic_json::to_ubjson ( const basic_json j,
const bool  use_size = false,
const bool  use_type = false 
)
inlinestatic

create a UBJSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_ubjson/

Definition at line 21056 of file json.hpp.

◆ to_ubjson() [2/3]

static void nlohmann::basic_json::to_ubjson ( const basic_json j,
detail::output_adapter< char >  o,
const bool  use_size = false,
const bool  use_type = false 
)
inlinestatic

create a UBJSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_ubjson/

Definition at line 21075 of file json.hpp.

◆ to_ubjson() [3/3]

static void nlohmann::basic_json::to_ubjson ( const basic_json j,
detail::output_adapter< std::uint8_t >  o,
const bool  use_size = false,
const bool  use_type = false 
)
inlinestatic

create a UBJSON serialization of a given JSON value

See also
https://json.nlohmann.me/api/basic_json/to_ubjson/

Definition at line 21067 of file json.hpp.

◆ type()

constexpr value_t nlohmann::basic_json::type ( ) const
inlineconstexprnoexcept

return the type of the JSON value (explicit)

See also
https://json.nlohmann.me/api/basic_json/type/

Definition at line 18448 of file json.hpp.

◆ type_name()

const JSON_HEDLEY_RETURNS_NON_NULL char* nlohmann::basic_json::type_name ( ) const
inlinenoexcept

return the type as string

See also
https://json.nlohmann.me/api/basic_json/type_name/

Definition at line 20957 of file json.hpp.

◆ unflatten()

basic_json nlohmann::basic_json::unflatten ( ) const
inline

unflatten a previously flattened JSON value

See also
https://json.nlohmann.me/api/basic_json/unflatten/

Definition at line 21372 of file json.hpp.

◆ update() [1/2]

void nlohmann::basic_json::update ( const_iterator  first,
const_iterator  last,
bool  merge_objects = false 
)
inline

updates a JSON object from another object, overwriting existing keys

See also
https://json.nlohmann.me/api/basic_json/update/

Definition at line 20313 of file json.hpp.

◆ update() [2/2]

void nlohmann::basic_json::update ( const_reference  j,
bool  merge_objects = false 
)
inline

updates a JSON object from another object, overwriting existing keys

See also
https://json.nlohmann.me/api/basic_json/update/

Definition at line 20306 of file json.hpp.

◆ value() [1/4]

string_t nlohmann::basic_json::value ( const json_pointer ptr,
const char *  default_value 
) const
inline

access specified object element via JSON Pointer with default value

See also
https://json.nlohmann.me/api/basic_json/value/ overload for a default value of type const char*

Definition at line 19372 of file json.hpp.

◆ value() [2/4]

template<class ValueType , typename std::enable_if< detail::is_getable< basic_json_t, ValueType >::value, int >::type = 0>
ValueType nlohmann::basic_json::value ( const json_pointer ptr,
const ValueType &  default_value 
) const
inline

access specified object element via JSON Pointer with default value

See also
https://json.nlohmann.me/api/basic_json/value/

Definition at line 19349 of file json.hpp.

◆ value() [3/4]

string_t nlohmann::basic_json::value ( const typename object_t::key_type &  key,
const char *  default_value 
) const
inline

access specified object element with default value

See also
https://json.nlohmann.me/api/basic_json/value/ overload for a default value of type const char*

Definition at line 19340 of file json.hpp.

◆ value() [4/4]

template<class ValueType , typename std::enable_if< detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, ValueType >::value, int >::type = 0>
ValueType nlohmann::basic_json::value ( const typename object_t::key_type &  key,
const ValueType &  default_value 
) const
inline

access specified object element with default value

See also
https://json.nlohmann.me/api/basic_json/value/ using std::is_convertible in a std::enable_if will fail when using explicit conversions

Definition at line 19319 of file json.hpp.

Friends And Related Function Documentation

◆ ::nlohmann::detail::binary_reader

template<typename BasicJsonType , typename InputType , typename SAX >
friend class ::nlohmann::detail::binary_reader
friend

Definition at line 17295 of file json.hpp.

◆ ::nlohmann::detail::binary_writer

template<typename BasicJsonType , typename CharType >
friend class ::nlohmann::detail::binary_writer
friend

Definition at line 17293 of file json.hpp.

◆ ::nlohmann::detail::exception

friend class ::nlohmann::detail::exception
friend

Definition at line 17300 of file json.hpp.

◆ ::nlohmann::detail::iter_impl

template<typename BasicJsonType >
friend class ::nlohmann::detail::iter_impl
friend

Definition at line 17291 of file json.hpp.

◆ ::nlohmann::detail::json_sax_dom_callback_parser

template<typename BasicJsonType >
friend class ::nlohmann::detail::json_sax_dom_callback_parser
friend

Definition at line 17299 of file json.hpp.

◆ ::nlohmann::detail::json_sax_dom_parser

template<typename BasicJsonType >
friend class ::nlohmann::detail::json_sax_dom_parser
friend

Definition at line 17297 of file json.hpp.

◆ ::nlohmann::detail::parser

template<typename BasicJsonType , typename InputType >
friend class ::nlohmann::detail::parser
friend

Definition at line 17288 of file json.hpp.

◆ detail::external_constructor

template<detail::value_t >
friend struct detail::external_constructor
friend

Definition at line 17284 of file json.hpp.

◆ operator!= [1/3]

bool operator!= ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: not equal

See also
https://json.nlohmann.me/api/basic_json/operator_ne/

Definition at line 20570 of file json.hpp.

◆ operator!= [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator!= ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: not equal

See also
https://json.nlohmann.me/api/basic_json/operator_ne/

Definition at line 20579 of file json.hpp.

◆ operator!= [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator!= ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: not equal

See also
https://json.nlohmann.me/api/basic_json/operator_ne/

Definition at line 20588 of file json.hpp.

◆ operator< [1/3]

bool operator< ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: less than

See also
https://json.nlohmann.me/api/basic_json/operator_lt/

Definition at line 20595 of file json.hpp.

◆ operator< [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator< ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: less than

See also
https://json.nlohmann.me/api/basic_json/operator_lt/

Definition at line 20673 of file json.hpp.

◆ operator< [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator< ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: less than

See also
https://json.nlohmann.me/api/basic_json/operator_lt/

Definition at line 20682 of file json.hpp.

◆ operator<< [1/2]

std::istream& operator<< ( basic_json j,
std::istream &  i 
)
friend

deserialize from stream

See also
https://json.nlohmann.me/api/basic_json/operator_gtgt/
Deprecated:
This stream operator is deprecated since 3.0.0 and will be removed in version 4.0.0 of the library. Please use operator>>(std::istream&, basic_json&) instead; that is, replace calls like j << i; with i >> j;.

Definition at line 20935 of file json.hpp.

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  o,
const basic_json j 
)
friend

serialize to stream

See also
https://json.nlohmann.me/api/basic_json/operator_ltlt/

Definition at line 20773 of file json.hpp.

◆ operator<= [1/3]

bool operator<= ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: less than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_le/

Definition at line 20689 of file json.hpp.

◆ operator<= [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator<= ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: less than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_le/

Definition at line 20698 of file json.hpp.

◆ operator<= [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator<= ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: less than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_le/

Definition at line 20707 of file json.hpp.

◆ operator== [1/3]

bool operator== ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: equal

See also
https://json.nlohmann.me/api/basic_json/operator_eq/

Definition at line 20474 of file json.hpp.

◆ operator== [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator== ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: equal

See also
https://json.nlohmann.me/api/basic_json/operator_eq/

Definition at line 20554 of file json.hpp.

◆ operator== [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator== ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: equal

See also
https://json.nlohmann.me/api/basic_json/operator_eq/

Definition at line 20563 of file json.hpp.

◆ operator> [1/3]

bool operator> ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: greater than

See also
https://json.nlohmann.me/api/basic_json/operator_gt/

Definition at line 20714 of file json.hpp.

◆ operator> [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator> ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: greater than

See also
https://json.nlohmann.me/api/basic_json/operator_gt/

Definition at line 20723 of file json.hpp.

◆ operator> [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator> ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: greater than

See also
https://json.nlohmann.me/api/basic_json/operator_gt/

Definition at line 20732 of file json.hpp.

◆ operator>= [1/3]

bool operator>= ( const_reference  lhs,
const_reference  rhs 
)
friend

comparison: greater than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_ge/

Definition at line 20739 of file json.hpp.

◆ operator>= [2/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator>= ( const_reference  lhs,
ScalarType  rhs 
)
friend

comparison: greater than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_ge/

Definition at line 20748 of file json.hpp.

◆ operator>= [3/3]

template<typename ScalarType , typename std::enable_if< std::is_scalar< ScalarType >::value, int >::type = 0>
bool operator>= ( ScalarType  lhs,
const_reference  rhs 
)
friend

comparison: greater than or equal

See also
https://json.nlohmann.me/api/basic_json/operator_ge/

Definition at line 20757 of file json.hpp.

◆ operator>> [1/2]

std::ostream& operator>> ( const basic_json j,
std::ostream &  o 
)
friend

serialize to stream

See also
https://json.nlohmann.me/api/basic_json/operator_ltlt/
Deprecated:
This function is deprecated since 3.0.0 and will be removed in version 4.0.0 of the library. Please use operator<<(std::ostream&, const basic_json&) instead; that is, replace calls like j >> o; with o << j;.

Definition at line 20795 of file json.hpp.

◆ operator>> [2/2]

std::istream& operator>> ( std::istream &  i,
basic_json j 
)
friend

deserialize from stream

See also
https://json.nlohmann.me/api/basic_json/operator_gtgt/

Definition at line 20942 of file json.hpp.

◆ swap

void swap ( reference  left,
reference  right 
)
friend

exchanges the values

See also
https://json.nlohmann.me/api/basic_json/swap/

Definition at line 20377 of file json.hpp.

Member Data Documentation

◆ __pad0__

JSON_PRIVATE_UNLESS_TESTED nlohmann::basic_json::__pad0__
private

Definition at line 17307 of file json.hpp.

◆ __pad1__

JSON_PRIVATE_UNLESS_TESTED nlohmann::basic_json::__pad1__
private

Definition at line 17339 of file json.hpp.

◆ __pad2__

JSON_PRIVATE_UNLESS_TESTED nlohmann::basic_json::__pad2__
private

Definition at line 17594 of file json.hpp.

◆ __pad3__

JSON_PRIVATE_UNLESS_TESTED nlohmann::basic_json::__pad3__

Definition at line 20990 of file json.hpp.

◆ array

array_t* nlohmann::basic_json::array
private

array (stored with pointer to save storage)

Definition at line 17596 of file json.hpp.

◆ binary

binary_t* nlohmann::basic_json::binary
private

binary (stored with pointer to save storage)

Definition at line 17600 of file json.hpp.

◆ boolean

boolean_t nlohmann::basic_json::boolean
private

boolean

Definition at line 17602 of file json.hpp.

◆ m_value

json_value nlohmann::basic_json::m_value = {}

the value of the current element

Definition at line 20993 of file json.hpp.

◆ number_float

number_float_t nlohmann::basic_json::number_float
private

number (floating-point)

Definition at line 17608 of file json.hpp.

◆ number_integer

number_integer_t nlohmann::basic_json::number_integer
private

number (integer)

Definition at line 17604 of file json.hpp.

◆ number_unsigned

number_unsigned_t nlohmann::basic_json::number_unsigned
private

number (unsigned integer)

Definition at line 17606 of file json.hpp.

◆ string

string_t* nlohmann::basic_json::string
private

string (stored with pointer to save storage)

Definition at line 17598 of file json.hpp.


The documentation for this class was generated from the following file:
nlohmann::detail::from_json
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:3834
mqtt_test.ret
ret
Definition: mqtt_test.py:30


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:52