|
Template
|
namespace for Niels Lohmann More...
#include <json.hpp>
Inherits nlohmann::detail::json_base_class< void >.
Public Types | |
| using | value_t = detail::value_t |
| using | json_pointer = ::nlohmann::json_pointer< StringType > |
| JSON Pointer, see nlohmann::json_pointer. | |
| template<typename T , typename SFINAE > | |
| using | json_serializer = JSONSerializer< T, SFINAE > |
| using | error_handler_t = detail::error_handler_t |
| how to treat decoding errors | |
| using | cbor_tag_handler_t = detail::cbor_tag_handler_t |
| how to treat CBOR tags | |
| using | initializer_list_t = std::initializer_list< detail::json_ref< basic_json > > |
| helper type for initializer lists of basic_json values | |
| using | input_format_t = detail::input_format_t |
| using | json_sax_t = json_sax< basic_json > |
| SAX interface type, see nlohmann::json_sax. | |
| using | parse_event_t = detail::parse_event_t |
| parser event types | |
| using | parser_callback_t = detail::parser_callback_t< basic_json > |
| per-element parser callback type | |
Public Member Functions | |
| JSON_HEDLEY_RETURNS_NON_NULL const char * | type_name () const noexcept |
| return the type as string | |
| data (const value_t v) | |
| data (size_type cnt, const basic_json &val) | |
| data () noexcept=default | |
| data (data &&) noexcept=default | |
| data (const data &) noexcept=delete | |
| data & | operator= (data &&) noexcept=delete |
| data & | operator= (const data &) noexcept=delete |
| ~data () noexcept | |
Static Public Member Functions | |
| static allocator_type | get_allocator () |
| returns the allocator associated with the container | |
| static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json | meta () |
| returns version information on the library | |
| JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool | sax_parse (InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false) |
| 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 | |
| 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 | |
Public Attributes | |
| JSON_PRIVATE_UNLESS_TESTED | : struct data { value_t m_type = value_t::null |
| json_value | m_value = {} |
| the value of the current element | |
| data | m_data = {} |
Friends | |
| template<detail::value_t > | |
| struct | detail::external_constructor |
| template<typename > | |
| class | ::nlohmann::json_pointer |
| template<typename BasicJsonType , typename InputType > | |
| class | ::nlohmann::detail::parser |
| template<typename BasicJsonType > | |
| class | ::nlohmann::detail::iter_impl |
| template<typename BasicJsonType , typename CharType > | |
| class | ::nlohmann::detail::binary_writer |
| template<typename BasicJsonType , typename InputType , typename SAX > | |
| class | ::nlohmann::detail::binary_reader |
| template<typename BasicJsonType > | |
| class | ::nlohmann::detail::json_sax_dom_parser |
| template<typename BasicJsonType > | |
| class | ::nlohmann::detail::json_sax_dom_callback_parser |
| class | ::nlohmann::detail::exception |
| std::istream & | operator<< (basic_json &j, std::istream &i) |
| deserialize from stream | |
| std::istream & | operator>> (std::istream &i, basic_json &j) |
| deserialize from stream | |
element access | |
Access to the JSON value. | |
| reference | at (size_type idx) |
| access specified array element with bounds checking | |
| const_reference | at (size_type idx) const |
| access specified array element with bounds checking | |
| reference | at (const typename object_t::key_type &key) |
| access specified object element with bounds checking | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| reference | at (KeyType &&key) |
| access specified object element with bounds checking | |
| const_reference | at (const typename object_t::key_type &key) const |
| access specified object element with bounds checking | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| const_reference | at (KeyType &&key) const |
| access specified object element with bounds checking | |
| reference | operator[] (size_type idx) |
| access specified array element | |
| const_reference | operator[] (size_type idx) const |
| access specified array element | |
| reference | operator[] (typename object_t::key_type key) |
| access specified object element | |
| const_reference | operator[] (const typename object_t::key_type &key) const |
| access specified object element | |
| template<typename T > | |
| reference | operator[] (T *key) |
| template<typename T > | |
| const_reference | operator[] (T *key) const |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| reference | operator[] (KeyType &&key) |
| access specified object element | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| const_reference | operator[] (KeyType &&key) const |
| access specified object element | |
| template<class ValueType , detail::enable_if_t< !detail::is_transparent< object_comparator_t >::value &&detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ValueType | value (const typename object_t::key_type &key, const ValueType &default_value) const |
| access specified object element with default value | |
| template<class ValueType , class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t< !detail::is_transparent< object_comparator_t >::value &&detail::is_getable< basic_json_t, ReturnType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ReturnType | value (const typename object_t::key_type &key, ValueType &&default_value) const |
| access specified object element with default value | |
| template<class ValueType , class KeyType , detail::enable_if_t< detail::is_transparent< object_comparator_t >::value &&!detail::is_json_pointer< KeyType >::value &&is_comparable_with_object_key< KeyType >::value &&detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ValueType | value (KeyType &&key, const ValueType &default_value) const |
| access specified object element with default value | |
| template<class ValueType , class KeyType , class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t< detail::is_transparent< object_comparator_t >::value &&!detail::is_json_pointer< KeyType >::value &&is_comparable_with_object_key< KeyType >::value &&detail::is_getable< basic_json_t, ReturnType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ReturnType | value (KeyType &&key, ValueType &&default_value) const |
| access specified object element via JSON Pointer with default value | |
| template<class ValueType , detail::enable_if_t< detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ValueType | value (const json_pointer &ptr, const ValueType &default_value) const |
| access specified object element via JSON Pointer with default value | |
| template<class ValueType , class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t< detail::is_getable< basic_json_t, ReturnType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ReturnType | value (const json_pointer &ptr, ValueType &&default_value) const |
| access specified object element via JSON Pointer with default value | |
| template<class ValueType , class BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ValueType | value (const ::nlohmann::json_pointer< BasicJsonType > &ptr, const ValueType &default_value) const |
| template<class ValueType , class BasicJsonType , class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&detail::is_getable< basic_json_t, ReturnType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType > >::value, int > = 0> | |
| ReturnType | value (const ::nlohmann::json_pointer< BasicJsonType > &ptr, ValueType &&default_value) const |
| reference | front () |
| access the first element | |
| const_reference | front () const |
| access the first element | |
| reference | back () |
| access the last element | |
| const_reference | back () const |
| access the last element | |
| template<class IteratorType , detail::enable_if_t< std::is_same< IteratorType, typename basic_json_t::iterator >::value||std::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int > = 0> | |
| IteratorType | erase (IteratorType pos) |
| remove element given an iterator | |
| template<class IteratorType , detail::enable_if_t< std::is_same< IteratorType, typename basic_json_t::iterator >::value||std::is_same< IteratorType, typename basic_json_t::const_iterator >::value, int > = 0> | |
| IteratorType | erase (IteratorType first, IteratorType last) |
| remove elements given an iterator range | |
| size_type | erase (const typename object_t::key_type &key) |
| remove element from a JSON object given a key | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| size_type | erase (KeyType &&key) |
| remove element from a JSON object given a key | |
| void | erase (const size_type idx) |
| remove element from a JSON array given an index | |
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 | |
| using | reference = value_type & |
| the type of an element reference | |
| using | const_reference = const value_type & |
| the type of an element const reference | |
| using | difference_type = std::ptrdiff_t |
| a type to represent differences between iterators | |
| using | size_type = std::size_t |
| a type to represent container sizes | |
| using | allocator_type = AllocatorType< basic_json > |
| the allocator type | |
| using | pointer = typename std::allocator_traits< allocator_type >::pointer |
| the type of an element pointer | |
| using | const_pointer = typename std::allocator_traits< allocator_type >::const_pointer |
| the type of an element const pointer | |
| using | iterator = iter_impl< basic_json > |
| an iterator for a basic_json container | |
| using | const_iterator = iter_impl< const basic_json > |
| a const iterator for a basic_json container | |
| using | reverse_iterator = json_reverse_iterator< typename basic_json::iterator > |
| a reverse iterator for a basic_json container | |
| using | const_reverse_iterator = json_reverse_iterator< typename basic_json::const_iterator > |
| a const reverse iterator for a basic_json container | |
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 | default_object_comparator_t = std::less< StringType > |
| default object key comparator type The actual object key comparator type (object_comparator_t) may be different. | |
| using | object_t = ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > |
| a type for an object | |
| using | array_t = ArrayType< basic_json, AllocatorType< basic_json > > |
| a type for an array | |
| using | string_t = StringType |
| a type for a string | |
| using | boolean_t = BooleanType |
| a type for a boolean | |
| using | number_integer_t = NumberIntegerType |
| a type for a number (integer) | |
| using | number_unsigned_t = NumberUnsignedType |
| a type for a number (unsigned) | |
| using | number_float_t = NumberFloatType |
| a type for a number (floating-point) | |
| using | binary_t = nlohmann::byte_container_with_subtype< BinaryType > |
| a type for a packed binary type | |
| using | object_comparator_t = detail::actual_object_comparator_t< basic_json > |
| object key comparator type | |
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 | |
| void | clear () noexcept |
| clears the contents | |
| void | push_back (basic_json &&val) |
| add an object to an array | |
| reference | operator+= (basic_json &&val) |
| add an object to an array | |
| void | push_back (const basic_json &val) |
| add an object to an array | |
| reference | operator+= (const basic_json &val) |
| add an object to an array | |
| void | push_back (const typename object_t::value_type &val) |
| add an object to an object | |
| reference | operator+= (const typename object_t::value_type &val) |
| add an object to an object | |
| void | push_back (initializer_list_t init) |
| add an object to an object | |
| reference | operator+= (initializer_list_t init) |
| add an object to an object | |
| template<class... Args> | |
| reference | emplace_back (Args &&... args) |
| add an object to an array | |
| template<class... Args> | |
| std::pair< iterator, bool > | emplace (Args &&... args) |
| add an object to an object if key does not exist | |
| template<typename... Args> | |
| iterator | insert_iterator (const_iterator pos, Args &&... args) |
| iterator | insert (const_iterator pos, const basic_json &val) |
| inserts element into array | |
| iterator | insert (const_iterator pos, basic_json &&val) |
| inserts element into array | |
| iterator | insert (const_iterator pos, size_type cnt, const basic_json &val) |
| inserts copies of element into array | |
| iterator | insert (const_iterator pos, const_iterator first, const_iterator last) |
| inserts range of elements into array | |
| iterator | insert (const_iterator pos, initializer_list_t ilist) |
| inserts elements from initializer list into array | |
| void | insert (const_iterator first, const_iterator last) |
| inserts range of elements into object | |
| void | update (const_reference j, bool merge_objects=false) |
| updates a JSON object from another object, overwriting existing keys | |
| void | update (const_iterator first, const_iterator last, bool merge_objects=false) |
| updates a JSON object from another object, overwriting existing keys | |
| 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 | |
| void | swap (array_t &other) |
| exchanges the values | |
| void | swap (object_t &other) |
| exchanges the values | |
| void | swap (string_t &other) |
| exchanges the values | |
| void | swap (binary_t &other) |
| exchanges the values | |
| void | swap (typename binary_t::container_type &other) |
| exchanges the values | |
lexicographical comparison operators | |
| JSON_PRIVATE_UNLESS_TESTED | : static bool compares_unordered(const_reference lhs |
| JSON_PRIVATE_UNLESS_TESTED const_reference | rhs |
| JSON_PRIVATE_UNLESS_TESTED const_reference bool | inverse |
value access | |
Direct access to the stored value of a JSON value. | |
| 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) | |
| 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) | |
| 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) | |
| 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) | |
| 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) | |
| 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) | |
| 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) | |
| template<typename ValueType , typename std::enable_if< detail::conjunction< detail::negation< std::is_pointer< ValueType > >, detail::negation< std::is_same< ValueType, std::nullptr_t > >, 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) | |
| binary_t & | get_binary () |
| get a binary value | |
| const binary_t & | get_binary () const |
| get a binary value | |
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) | |
| 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) | |
| static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json | binary (typename binary_t::container_type &&init) |
| explicitly create a binary array | |
| 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) | |
| static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json | array (initializer_list_t init={}) |
| explicitly create an array from an initializer list | |
| static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json | object (initializer_list_t init={}) |
| explicitly create an object from an initializer list | |
| basic_json (const value_t v) | |
| create an empty value with a given type | |
| basic_json (std::nullptr_t=nullptr) noexcept | |
| create a null object | |
| 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 | |
| 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 | |
| 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 | |
| basic_json (size_type cnt, const basic_json &val) | |
| construct an array with count copies of given value | |
| 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 | |
| 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 | |
| basic_json (basic_json &&other) noexcept | |
| move constructor | |
| basic_json & | operator= (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 &&std::is_nothrow_move_assignable< json_base_class_t >::value) |
| copy assignment | |
| ~basic_json () noexcept | |
| destructor | |
iterators | |
| static iteration_proxy< iterator > | iterator_wrapper (reference ref) noexcept |
| wrapper to access iterator member functions in range-based for | |
| static iteration_proxy< const_iterator > | iterator_wrapper (const_reference ref) noexcept |
| wrapper to access iterator member functions in range-based for | |
| iterator | begin () noexcept |
| returns an iterator to the first element | |
| const_iterator | begin () const noexcept |
| returns an iterator to the first element | |
| const_iterator | cbegin () const noexcept |
| returns a const iterator to the first element | |
| iterator | end () noexcept |
| returns an iterator to one past the last element | |
| const_iterator | end () const noexcept |
| returns an iterator to one past the last element | |
| const_iterator | cend () const noexcept |
| returns an iterator to one past the last element | |
| reverse_iterator | rbegin () noexcept |
| returns an iterator to the reverse-beginning | |
| const_reverse_iterator | rbegin () const noexcept |
| returns an iterator to the reverse-beginning | |
| reverse_iterator | rend () noexcept |
| returns an iterator to the reverse-end | |
| const_reverse_iterator | rend () const noexcept |
| returns an iterator to the reverse-end | |
| const_reverse_iterator | crbegin () const noexcept |
| returns a const reverse iterator to the last element | |
| const_reverse_iterator | crend () const noexcept |
| returns a const reverse iterator to one before the first | |
| iteration_proxy< iterator > | items () noexcept |
| helper to access iterator member functions in range-based for | |
| iteration_proxy< const_iterator > | items () const noexcept |
| helper to access iterator member functions in range-based for | |
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 | |
| static void | to_cbor (const basic_json &j, detail::output_adapter< std::uint8_t > o) |
| create a CBOR serialization of a given JSON value | |
| static void | to_cbor (const basic_json &j, detail::output_adapter< char > o) |
| create a CBOR serialization of a given JSON value | |
| static std::vector< std::uint8_t > | to_msgpack (const basic_json &j) |
| create a MessagePack serialization of a given JSON value | |
| static void | to_msgpack (const basic_json &j, detail::output_adapter< std::uint8_t > o) |
| create a MessagePack serialization of a given JSON value | |
| static void | to_msgpack (const basic_json &j, detail::output_adapter< char > o) |
| create a MessagePack serialization of a given JSON value | |
| 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 | |
| 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 | |
| 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 | |
| static std::vector< std::uint8_t > | to_bjdata (const basic_json &j, const bool use_size=false, const bool use_type=false) |
| create a BJData serialization of a given JSON value | |
| static void | to_bjdata (const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false) |
| create a BJData serialization of a given JSON value | |
| static void | to_bjdata (const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false) |
| create a BJData serialization of a given JSON value | |
| static std::vector< std::uint8_t > | to_bson (const basic_json &j) |
| create a BSON serialization of a given JSON value | |
| static void | to_bson (const basic_json &j, detail::output_adapter< std::uint8_t > o) |
| create a BSON serialization of a given JSON value | |
| static void | to_bson (const basic_json &j, detail::output_adapter< char > o) |
| create a BSON serialization of a given JSON value | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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 | |
| 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_bjdata (InputType &&i, const bool strict=true, const bool allow_exceptions=true) |
| create a JSON value from an input in BJData format | |
| template<typename IteratorType > | |
| static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json | from_bjdata (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true) |
| create a JSON value from an input in BJData format | |
| 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 | |
| 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 | |
| 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 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 | |
| void | patch_inplace (const basic_json &json_patch) |
| applies a JSON patch in-place without copying the object | |
| basic_json | patch (const basic_json &json_patch) const |
| applies a JSON patch to a copy of the current object | |
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 | |
| constexpr value_t | type () const noexcept |
| return the type of the JSON value (explicit) | |
| constexpr bool | is_primitive () const noexcept |
| return whether type is primitive | |
| constexpr bool | is_structured () const noexcept |
| return whether type is structured | |
| constexpr bool | is_null () const noexcept |
| return whether value is null | |
| constexpr bool | is_boolean () const noexcept |
| return whether value is a boolean | |
| constexpr bool | is_number () const noexcept |
| return whether value is a number | |
| constexpr bool | is_number_integer () const noexcept |
| return whether value is an integer number | |
| constexpr bool | is_number_unsigned () const noexcept |
| return whether value is an unsigned integer number | |
| constexpr bool | is_number_float () const noexcept |
| return whether value is a floating-point number | |
| constexpr bool | is_object () const noexcept |
| return whether value is an object | |
| constexpr bool | is_array () const noexcept |
| return whether value is an array | |
| constexpr bool | is_string () const noexcept |
| return whether value is a string | |
| constexpr bool | is_binary () const noexcept |
| return whether value is a binary array | |
| constexpr bool | is_discarded () const noexcept |
| return whether value is discarded | |
| constexpr | operator value_t () const noexcept |
| return the type of the JSON value (implicit) | |
lookup | |
| iterator | find (const typename object_t::key_type &key) |
| find an element in a JSON object | |
| const_iterator | find (const typename object_t::key_type &key) const |
| find an element in a JSON object | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| iterator | find (KeyType &&key) |
| find an element in a JSON object | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| const_iterator | find (KeyType &&key) const |
| find an element in a JSON object | |
| size_type | count (const typename object_t::key_type &key) const |
| returns the number of occurrences of a key in a JSON object | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| size_type | count (KeyType &&key) const |
| returns the number of occurrences of a key in a JSON object | |
| bool | contains (const typename object_t::key_type &key) const |
| check the existence of an element in a JSON object | |
| template<class KeyType , detail::enable_if_t< detail::is_usable_as_basic_json_key_type< basic_json_t, KeyType >::value, int > = 0> | |
| bool | contains (KeyType &&key) const |
| check the existence of an element in a JSON object | |
| bool | contains (const json_pointer &ptr) const |
| check the existence of an element in a JSON object given a JSON pointer | |
| template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> | |
| bool | contains (const typename ::nlohmann::json_pointer< BasicJsonType > &ptr) const |
capacity | |
| bool | empty () const noexcept |
| checks whether the container is empty. | |
| size_type | size () const noexcept |
| returns the number of elements | |
| size_type | max_size () const noexcept |
| returns the maximum possible number of elements | |
JSON Pointer functions | |
| reference | operator[] (const json_pointer &ptr) |
| access specified element via JSON Pointer | |
| template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> | |
| reference | operator[] (const ::nlohmann::json_pointer< BasicJsonType > &ptr) |
| const_reference | operator[] (const json_pointer &ptr) const |
| access specified element via JSON Pointer | |
| template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> | |
| const_reference | operator[] (const ::nlohmann::json_pointer< BasicJsonType > &ptr) const |
| reference | at (const json_pointer &ptr) |
| access specified element via JSON Pointer | |
| template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> | |
| reference | at (const ::nlohmann::json_pointer< BasicJsonType > &ptr) |
| const_reference | at (const json_pointer &ptr) const |
| access specified element via JSON Pointer | |
| template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> | |
| const_reference | at (const ::nlohmann::json_pointer< BasicJsonType > &ptr) const |
| basic_json | flatten () const |
| return flattened JSON value | |
| basic_json | unflatten () const |
| unflatten a previously flattened JSON value | |
JSON Merge Patch functions | |
| void | merge_patch (const basic_json &apply_patch) |
| applies a JSON Merge Patch | |
Detailed Description
class basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >
namespace for Niels Lohmann
a class to store JSON values
- Since
- version 1.0.0
a class to store JSON values
- Invariant
- The member variables m_value and m_type have the following relationship:
- If
m_type == value_t::object, thenm_value.object != nullptr. - If
m_type == value_t::array, thenm_value.array != nullptr. - If
m_type == value_t::string, thenm_value.string != nullptr. The invariants are checked by member function assert_invariant().
- If
- Note
- ObjectType trick from https://stackoverflow.com/a/9860911
- Since
- version 1.0.0
Member Typedef Documentation
◆ allocator_type
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::allocator_type = AllocatorType<basic_json> |
◆ array_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::array_t = ArrayType<basic_json, AllocatorType<basic_json> > |
a type for an array
◆ binary_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::binary_t = nlohmann::byte_container_with_subtype<BinaryType> |
a type for a packed binary type
◆ boolean_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::boolean_t = BooleanType |
a type for a boolean
◆ cbor_tag_handler_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::cbor_tag_handler_t = detail::cbor_tag_handler_t |
◆ const_iterator
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::const_iterator = iter_impl<const basic_json> |
a const iterator for a basic_json container
◆ const_pointer
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::const_pointer = typename std::allocator_traits<allocator_type>::const_pointer |
◆ const_reference
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::const_reference = const value_type& |
◆ const_reverse_iterator
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator> |
a const reverse iterator for a basic_json container
◆ default_object_comparator_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::default_object_comparator_t = std::less<StringType> |
default object key comparator type The actual object key comparator type (object_comparator_t) may be different.
◆ difference_type
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::difference_type = std::ptrdiff_t |
◆ error_handler_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::error_handler_t = detail::error_handler_t |
◆ exception
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::exception = detail::exception |
◆ initializer_list_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::initializer_list_t = std::initializer_list<detail::json_ref<basic_json> > |
helper type for initializer lists of basic_json values
◆ input_format_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::input_format_t = detail::input_format_t |
◆ invalid_iterator
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::invalid_iterator = detail::invalid_iterator |
◆ iterator
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::iterator = iter_impl<basic_json> |
an iterator for a basic_json container
◆ json_pointer
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::json_pointer = ::nlohmann::json_pointer<StringType> |
◆ json_sax_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::json_sax_t = json_sax<basic_json> |
◆ json_serializer
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::json_serializer = JSONSerializer<T, SFINAE> |
◆ number_float_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::number_float_t = NumberFloatType |
a type for a number (floating-point)
◆ number_integer_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::number_integer_t = NumberIntegerType |
a type for a number (integer)
◆ number_unsigned_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::number_unsigned_t = NumberUnsignedType |
a type for a number (unsigned)
◆ object_comparator_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::object_comparator_t = detail::actual_object_comparator_t<basic_json> |
object key comparator type
◆ object_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::object_t = ObjectType<StringType, basic_json, default_object_comparator_t, AllocatorType<std::pair<const StringType, basic_json> >> |
a type for an object
◆ other_error
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::other_error = detail::other_error |
◆ out_of_range
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::out_of_range = detail::out_of_range |
◆ parse_error
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::parse_error = detail::parse_error |
◆ parse_event_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::parse_event_t = detail::parse_event_t |
parser event types
◆ parser_callback_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::parser_callback_t = detail::parser_callback_t<basic_json> |
per-element parser callback type
◆ pointer
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::pointer = typename std::allocator_traits<allocator_type>::pointer |
◆ reference
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::reference = value_type& |
◆ reverse_iterator
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::reverse_iterator = json_reverse_iterator<typename basic_json::iterator> |
a reverse iterator for a basic_json container
◆ size_type
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::size_type = std::size_t |
◆ string_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::string_t = StringType |
a type for a string
◆ type_error
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::type_error = detail::type_error |
◆ value_t
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::value_t = detail::value_t |
◆ value_type
| using basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::value_type = basic_json |
the type of elements in a basic_json container
Constructor & Destructor Documentation
◆ basic_json() [1/10]
|
inline |
create an empty value with a given type
◆ basic_json() [2/10]
|
inlinenoexcept |
create a null object
◆ basic_json() [3/10]
|
inlinenoexcept |
create a JSON value from compatible types
◆ basic_json() [4/10]
|
inline |
create a JSON value from an existing one
◆ basic_json() [5/10]
|
inline |
create a container (array or object) from an initializer list
◆ basic_json() [6/10]
|
inline |
construct an array with count copies of given value
◆ basic_json() [7/10]
|
inline |
construct a JSON container given an iterator range
◆ basic_json() [8/10]
|
inline |
◆ basic_json() [9/10]
|
inline |
copy constructor
◆ basic_json() [10/10]
|
inlinenoexcept |
move constructor
◆ ~basic_json()
|
inlinenoexcept |
destructor
◆ ~data()
|
inlinenoexcept |
Member Function Documentation
◆ array()
|
inlinestatic |
explicitly create an array from an initializer list
◆ at() [1/10]
|
inline |
◆ at() [2/10]
|
inline |
◆ at() [3/10]
|
inline |
access specified element via JSON Pointer
◆ at() [4/10]
|
inline |
access specified element via JSON Pointer
◆ at() [5/10]
|
inline |
access specified object element with bounds checking
◆ at() [6/10]
|
inline |
access specified object element with bounds checking
◆ at() [7/10]
|
inline |
access specified object element with bounds checking
◆ at() [8/10]
|
inline |
access specified object element with bounds checking
◆ at() [9/10]
|
inline |
access specified array element with bounds checking
◆ at() [10/10]
|
inline |
access specified array element with bounds checking
◆ back() [1/2]
|
inline |
access the last element
◆ back() [2/2]
|
inline |
access the last element
◆ begin() [1/2]
|
inlinenoexcept |
returns an iterator to the first element
◆ begin() [2/2]
|
inlinenoexcept |
returns an iterator to the first element
◆ binary() [1/4]
|
inlinestatic |
explicitly create a binary array (without subtype)
◆ binary() [2/4]
|
inlinestatic |
explicitly create a binary array (with subtype)
◆ binary() [3/4]
|
inlinestatic |
explicitly create a binary array
◆ binary() [4/4]
|
inlinestatic |
explicitly create a binary array (with subtype)
◆ cbegin()
|
inlinenoexcept |
returns a const iterator to the first element
◆ cend()
|
inlinenoexcept |
returns an iterator to one past the last element
◆ clear()
|
inlinenoexcept |
clears the contents
◆ contains() [1/4]
|
inline |
check the existence of an element in a JSON object given a JSON pointer
◆ contains() [2/4]
|
inline |
◆ contains() [3/4]
|
inline |
check the existence of an element in a JSON object
◆ contains() [4/4]
|
inline |
check the existence of an element in a JSON object
◆ count() [1/2]
|
inline |
returns the number of occurrences of a key in a JSON object
◆ count() [2/2]
|
inline |
returns the number of occurrences of a key in a JSON object
◆ crbegin()
|
inlinenoexcept |
returns a const reverse iterator to the last element
◆ crend()
|
inlinenoexcept |
returns a const reverse iterator to one before the first
◆ data() [1/5]
|
defaultnoexcept |
◆ data() [2/5]
|
deletenoexcept |
◆ data() [3/5]
|
inline |
◆ data() [4/5]
|
defaultnoexcept |
◆ data() [5/5]
|
inline |
◆ diff()
|
inlinestatic |
creates a diff as a JSON patch
◆ dump()
|
inline |
serialization
◆ emplace()
|
inline |
add an object to an object if key does not exist
◆ emplace_back()
|
inline |
add an object to an array
◆ empty()
|
inlinenoexcept |
checks whether the container is empty.
◆ end() [1/2]
|
inlinenoexcept |
returns an iterator to one past the last element
◆ end() [2/2]
|
inlinenoexcept |
returns an iterator to one past the last element
◆ erase() [1/5]
|
inline |
remove element from a JSON array given an index
◆ erase() [2/5]
|
inline |
remove element from a JSON object given a key
◆ erase() [3/5]
|
inline |
remove elements given an iterator range
◆ erase() [4/5]
|
inline |
remove element given an iterator
◆ erase() [5/5]
|
inline |
remove element from a JSON object given a key
◆ find() [1/4]
|
inline |
find an element in a JSON object
◆ find() [2/4]
|
inline |
find an element in a JSON object
◆ find() [3/4]
|
inline |
find an element in a JSON object
◆ find() [4/4]
|
inline |
find an element in a JSON object
◆ flatten()
|
inline |
return flattened JSON value
◆ from_bjdata() [1/2]
|
inlinestatic |
create a JSON value from an input in BJData format
◆ from_bjdata() [2/2]
|
inlinestatic |
create a JSON value from an input in BJData format
◆ from_bson() [1/4]
|
inlinestatic |
◆ from_bson() [2/4]
|
inlinestatic |
◆ from_bson() [3/4]
|
inlinestatic |
create a JSON value from an input in BSON format
◆ from_bson() [4/4]
|
inlinestatic |
create a JSON value from an input in BSON format
◆ from_cbor() [1/4]
|
inlinestatic |
◆ from_cbor() [2/4]
|
inlinestatic |
◆ from_cbor() [3/4]
|
inlinestatic |
create a JSON value from an input in CBOR format
◆ from_cbor() [4/4]
|
inlinestatic |
create a JSON value from an input in CBOR format
◆ from_msgpack() [1/4]
|
inlinestatic |
◆ from_msgpack() [2/4]
|
inlinestatic |
◆ from_msgpack() [3/4]
|
inlinestatic |
create a JSON value from an input in MessagePack format
◆ from_msgpack() [4/4]
|
inlinestatic |
create a JSON value from an input in MessagePack format
◆ from_ubjson() [1/4]
|
inlinestatic |
◆ from_ubjson() [2/4]
|
inlinestatic |
◆ from_ubjson() [3/4]
|
inlinestatic |
create a JSON value from an input in UBJSON format
◆ from_ubjson() [4/4]
|
inlinestatic |
create a JSON value from an input in UBJSON format
◆ front() [1/2]
|
inline |
access the first element
◆ front() [2/2]
|
inline |
access the first element
◆ get() [1/2]
|
inlinenoexcept |
get a (pointer) value (explicit)
Performs explicit type conversion between the JSON value and a compatible value if required.
- If the requested type is a pointer to the internally stored JSON value that pointer is returned. No copies are made.
- If the requested type is the current basic_json, or a different basic_json convertible from the current basic_json.
- Otherwise the value is converted by calling the json_serializer<ValueType>
from_json()method.
- Template Parameters
-
ValueTypeCV the provided value type ValueType the returned value type
- Returns
- copy of the JSON value, converted to
- Template Parameters
-
ValueType if necessary
- Exceptions
-
what json_serializer<ValueType> from_json()method throws if conversion is required
- Since
- version 2.1.0
◆ get() [2/2]
|
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
-
PointerType pointer 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;
nullptrotherwise
@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
◆ get_allocator()
|
inlinestatic |
returns the allocator associated with the container
◆ get_binary() [1/2]
|
inline |
get a binary value
◆ get_binary() [2/2]
|
inline |
get a binary value
◆ get_ptr() [1/2]
|
inlineconstexprnoexcept |
get a pointer value (implicit)
◆ get_ptr() [2/2]
|
inlinenoexcept |
get a pointer value (implicit)
◆ get_ref() [1/2]
|
inline |
get a reference value (implicit)
◆ get_ref() [2/2]
|
inline |
get a reference value (implicit)
◆ get_to() [1/3]
|
inlinenoexcept |
◆ get_to() [2/3]
|
inline |
◆ get_to() [3/3]
|
inlinenoexcept |
get a value (explicit)
◆ insert() [1/6]
|
inline |
inserts range of elements into object
◆ insert() [2/6]
|
inline |
inserts element into array
◆ insert() [3/6]
|
inline |
inserts element into array
◆ insert() [4/6]
|
inline |
inserts range of elements into array
◆ insert() [5/6]
|
inline |
inserts elements from initializer list into array
◆ insert() [6/6]
|
inline |
inserts copies of element into array
◆ insert_iterator()
|
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
◆ is_array()
|
inlineconstexprnoexcept |
return whether value is an array
◆ is_binary()
|
inlineconstexprnoexcept |
return whether value is a binary array
◆ is_boolean()
|
inlineconstexprnoexcept |
return whether value is a boolean
◆ is_discarded()
|
inlineconstexprnoexcept |
return whether value is discarded
◆ is_null()
|
inlineconstexprnoexcept |
return whether value is null
◆ is_number()
|
inlineconstexprnoexcept |
return whether value is a number
◆ is_number_float()
|
inlineconstexprnoexcept |
return whether value is a floating-point number
◆ is_number_integer()
|
inlineconstexprnoexcept |
return whether value is an integer number
◆ is_number_unsigned()
|
inlineconstexprnoexcept |
return whether value is an unsigned integer number
◆ is_object()
|
inlineconstexprnoexcept |
return whether value is an object
◆ is_primitive()
|
inlineconstexprnoexcept |
return whether type is primitive
◆ is_string()
|
inlineconstexprnoexcept |
return whether value is a string
◆ is_structured()
|
inlineconstexprnoexcept |
return whether type is structured
◆ items() [1/2]
|
inlinenoexcept |
helper to access iterator member functions in range-based for
◆ items() [2/2]
|
inlinenoexcept |
helper to access iterator member functions in range-based for
◆ iterator_wrapper() [1/2]
|
inlinestaticnoexcept |
wrapper to access iterator member functions in range-based for
- 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)withj.items().
◆ iterator_wrapper() [2/2]
|
inlinestaticnoexcept |
wrapper to access iterator member functions in range-based for
- 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)withj.items().
◆ max_size()
|
inlinenoexcept |
returns the maximum possible number of elements
◆ merge_patch()
|
inline |
applies a JSON Merge Patch
◆ meta()
|
inlinestatic |
returns version information on the library
◆ object()
|
inlinestatic |
explicitly create an object from an initializer list
◆ operator value_t()
|
inlineconstexprnoexcept |
return the type of the JSON value (implicit)
◆ operator ValueType()
|
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
-
ValueType non-pointer type compatible to the JSON value, for instance intfor JSON integer numbers,boolfor JSON booleans, orstd::vectortypes 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 tostd::string.
- Returns
- copy of the JSON value, converted to type ValueType
- Exceptions
-
type_error.302 in 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
◆ operator+=() [1/4]
|
inline |
add an object to an array
◆ operator+=() [2/4]
|
inline |
add an object to an array
◆ operator+=() [3/4]
|
inline |
add an object to an object
◆ operator+=() [4/4]
|
inline |
add an object to an object
◆ operator=() [1/3]
|
inlinenoexcept |
copy assignment
◆ operator=() [2/3]
|
deletenoexcept |
◆ operator=() [3/3]
|
deletenoexcept |
◆ operator[]() [1/12]
|
inline |
◆ operator[]() [2/12]
|
inline |
◆ operator[]() [3/12]
|
inline |
access specified element via JSON Pointer
◆ operator[]() [4/12]
|
inline |
access specified element via JSON Pointer
◆ operator[]() [5/12]
|
inline |
access specified object element
◆ operator[]() [6/12]
|
inline |
access specified object element
◆ operator[]() [7/12]
|
inline |
access specified object element
◆ operator[]() [8/12]
|
inline |
access specified array element
◆ operator[]() [9/12]
|
inline |
access specified array element
◆ operator[]() [10/12]
|
inline |
◆ operator[]() [11/12]
|
inline |
◆ operator[]() [12/12]
|
inline |
access specified object element
◆ patch()
|
inline |
applies a JSON patch to a copy of the current object
◆ patch_inplace()
|
inline |
applies a JSON patch in-place without copying the object
◆ push_back() [1/4]
|
inline |
add an object to an array
◆ push_back() [2/4]
|
inline |
add an object to an array
◆ push_back() [3/4]
|
inline |
add an object to an object
◆ push_back() [4/4]
|
inline |
add an object to an object
◆ rbegin() [1/2]
|
inlinenoexcept |
returns an iterator to the reverse-beginning
◆ rbegin() [2/2]
|
inlinenoexcept |
returns an iterator to the reverse-beginning
◆ rend() [1/2]
|
inlinenoexcept |
returns an iterator to the reverse-end
◆ rend() [2/2]
|
inlinenoexcept |
returns an iterator to the reverse-end
◆ sax_parse() [1/3]
|
inlinestatic |
generate SAX events
- 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.
◆ sax_parse() [2/3]
|
inlinestatic |
◆ sax_parse() [3/3]
|
inlinestatic |
generate SAX events
◆ size()
|
inlinenoexcept |
returns the number of elements
◆ swap() [1/6]
|
inline |
exchanges the values
◆ swap() [2/6]
|
inline |
exchanges the values
◆ swap() [3/6]
|
inline |
exchanges the values
◆ swap() [4/6]
|
inlinenoexcept |
exchanges the values
◆ swap() [5/6]
|
inline |
exchanges the values
◆ swap() [6/6]
|
inline |
exchanges the values
◆ to_bjdata() [1/3]
|
inlinestatic |
create a BJData serialization of a given JSON value
◆ to_bjdata() [2/3]
|
inlinestatic |
create a BJData serialization of a given JSON value
◆ to_bjdata() [3/3]
|
inlinestatic |
create a BJData serialization of a given JSON value
◆ to_bson() [1/3]
|
inlinestatic |
create a BSON serialization of a given JSON value
◆ to_bson() [2/3]
|
inlinestatic |
create a BSON serialization of a given JSON value
◆ to_bson() [3/3]
|
inlinestatic |
create a BSON serialization of a given JSON value
◆ to_cbor() [1/3]
|
inlinestatic |
create a CBOR serialization of a given JSON value
◆ to_cbor() [2/3]
|
inlinestatic |
create a CBOR serialization of a given JSON value
◆ to_cbor() [3/3]
|
inlinestatic |
create a CBOR serialization of a given JSON value
◆ to_msgpack() [1/3]
|
inlinestatic |
create a MessagePack serialization of a given JSON value
◆ to_msgpack() [2/3]
|
inlinestatic |
create a MessagePack serialization of a given JSON value
◆ to_msgpack() [3/3]
|
inlinestatic |
create a MessagePack serialization of a given JSON value
◆ to_ubjson() [1/3]
|
inlinestatic |
create a UBJSON serialization of a given JSON value
◆ to_ubjson() [2/3]
|
inlinestatic |
create a UBJSON serialization of a given JSON value
◆ to_ubjson() [3/3]
|
inlinestatic |
create a UBJSON serialization of a given JSON value
◆ type()
|
inlineconstexprnoexcept |
return the type of the JSON value (explicit)
◆ type_name()
|
inlinenoexcept |
return the type as string
◆ unflatten()
|
inline |
unflatten a previously flattened JSON value
◆ update() [1/2]
|
inline |
updates a JSON object from another object, overwriting existing keys
◆ update() [2/2]
|
inline |
updates a JSON object from another object, overwriting existing keys
◆ value() [1/8]
|
inline |
◆ value() [2/8]
|
inline |
◆ value() [3/8]
|
inline |
access specified object element via JSON Pointer with default value
◆ value() [4/8]
|
inline |
access specified object element via JSON Pointer with default value
◆ value() [5/8]
|
inline |
access specified object element with default value
◆ value() [6/8]
|
inline |
access specified object element with default value
◆ value() [7/8]
|
inline |
access specified object element with default value
◆ value() [8/8]
|
inline |
access specified object element via JSON Pointer with default value
Friends And Related Symbol Documentation
◆ ::nlohmann::detail::binary_reader
|
friend |
◆ ::nlohmann::detail::binary_writer
|
friend |
◆ ::nlohmann::detail::exception
|
friend |
◆ ::nlohmann::detail::iter_impl
|
friend |
◆ ::nlohmann::detail::json_sax_dom_callback_parser
|
friend |
◆ ::nlohmann::detail::json_sax_dom_parser
|
friend |
◆ ::nlohmann::detail::parser
|
friend |
◆ ::nlohmann::json_pointer
|
friend |
◆ detail::external_constructor
|
friend |
◆ operator<<
|
friend |
deserialize from stream
- 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;withi >> j;.
◆ operator>>
|
friend |
deserialize from stream
◆ swap
|
friend |
exchanges the values
Member Data Documentation
◆ __pad3__
| JSON_PRIVATE_UNLESS_TESTED basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::__pad3__ |
◆ __pad4__
| JSON_PRIVATE_UNLESS_TESTED basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::__pad4__ |
◆ inverse
| JSON_PRIVATE_UNLESS_TESTED const_reference bool basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::inverse |
◆ m_data
| data basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::m_data = {} |
◆ m_value
| json_value basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::m_value = {} |
◆ rhs
| JSON_PRIVATE_UNLESS_TESTED const_reference basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::rhs |
The documentation for this class was generated from the following file:
- include/nlohmann/json.hpp
Generated by