Reference
Namespaces
Name |
Description |
nlohmann | namespace for Niels Lohmann |
Using Declarations
namespace for Niels Lohmann
Types
Functions
See Also
https://github.com/nlohmann
namespace for Niels Lohmann
Types
Functions
See Also
https://github.com/nlohmann
default specialization
Synopsis
Declared in <nlohmann/json_fwd.hpp>
using json = basic_json;
specialization that maintains the insertion order of object keys
default JSONSerializer template argument
Synopsis
Declared in <nlohmann/adl_serializer.hpp>
template<
typename T = void,
typename SFINAE = void>
struct adl_serializer;
Static Member Functions
Name |
Description |
from_json | convert a JSON value to any value type |
to_json | convert any value type to a JSON value |
Description
This serializer ignores the template arguments and uses ADL([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))for serialization.
convert a JSON value to any value type
Synopses
Declared in <nlohmann/adl_serializer.hpp>
convert a JSON value to any value type
template<
typename BasicJsonType,
typename TargetType = ValueType>
static
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
from_json(BasicJsonType&& j) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType>{})));
» more...
convert a JSON value to any value type
template<
typename BasicJsonType,
typename TargetType = ValueType>
static
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
from_json(
BasicJsonType&& j,
TargetType& val) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)));
» more...
convert a JSON value to any value type
Synopsis
Declared in <nlohmann/adl_serializer.hpp>
template<
typename BasicJsonType,
typename TargetType = ValueType>
static
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
from_json(BasicJsonType&& j) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType>{})));
convert a JSON value to any value type
Synopsis
Declared in <nlohmann/adl_serializer.hpp>
template<
typename BasicJsonType,
typename TargetType = ValueType>
static
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
from_json(
BasicJsonType&& j,
TargetType& val) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)));
convert any value type to a JSON value
Synopsis
Declared in <nlohmann/adl_serializer.hpp>
template<
typename BasicJsonType,
typename TargetType = ValueType>
static
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
to_json(
BasicJsonType& j,
TargetType&& val) noexcept(noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))));
Synopsis
Declared in <nlohmann/json.hpp>
template<>
class basic_json<>
: public nlohmann::detail::json_base_class<void>
Base Classes
Name |
Description |
nlohmann::detail::json_base_class<void> | |
Types
Member Functions
Static Member Functions
Friends
Name |
Description |
operator>> |
deserialize from stream |
operator<< |
deserialize from stream |
operator>> |
serialize to stream |
operator<< |
serialize to stream |
swap |
exchanges the values |
exception |
general exception of the basic_json class |
serializer |
|
json_pointer |
JSON Pointer defines a string syntax for identifying a specific value within a JSON document |
|===
the allocator type
Synopsis
Declared in <nlohmann/json.hpp>
using allocator_type = allocator<basic_json>;
a type for an array
Synopsis
Declared in <nlohmann/json.hpp>
using array_t = vector<basic_json, allocator<basic_json>>;
a type for a packed binary type
how to encode BJData
Synopsis
Declared in <nlohmann/json.hpp>
using bjdata_version_t = detail::bjdata_version_t;
a type for a boolean
Synopsis
Declared in <nlohmann/json.hpp>
using boolean_t = bool;
how to treat CBOR tags
Synopsis
Declared in <nlohmann/json.hpp>
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
a const iterator for a basic_json container
the type of an element const pointer
Synopsis
Declared in <nlohmann/json.hpp>
using const_pointer = std::allocator_traits<allocator_type>::const_pointer;
the type of an element const reference
Synopsis
Declared in <nlohmann/json.hpp>
using const_reference = value_type const&;
a const reverse iterator for a basic_json container
Synopsis
Declared in <nlohmann/json.hpp>
using default_object_comparator_t = std::less;
a type to represent differences between iterators
Synopsis
Declared in <nlohmann/json.hpp>
using difference_type = std::ptrdiff_t;
how to treat decoding errors
Synopsis
Declared in <nlohmann/json.hpp>
using error_handler_t = detail::error_handler_t;
Classes to implement user-defined exceptions. @{
Synopsis
Declared in <nlohmann/json.hpp>
using exception = detail::exception;
helper type for initializer lists of basic_json values
Synopsis
Declared in <nlohmann/json.hpp>
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
Synopsis
Declared in <nlohmann/json.hpp>
using input_format_t = detail::input_format_t;
Synopsis
Declared in <nlohmann/json.hpp>
using invalid_iterator = detail::invalid_iterator;
an iterator for a basic_json container
SAX interface type, see nlohmann::json_sax
Synopsis
Declared in <nlohmann/json.hpp>
using json_sax_t = json_sax<basic_json>;
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename T,
typename SFINAE>
using json_serializer = adl_serializer<T, SFINAE>;
a type for a number (floating-point)
Synopsis
Declared in <nlohmann/json.hpp>
using number_float_t = double;
a type for a number (integer)
Synopsis
Declared in <nlohmann/json.hpp>
using number_integer_t = long long;
a type for a number (unsigned)
Synopsis
Declared in <nlohmann/json.hpp>
using number_unsigned_t = unsigned long long;
object key comparator type
Synopsis
Declared in <nlohmann/json.hpp>
using object_comparator_t = detail::actual_object_comparator_t<basic_json>;
a type for an object
Synopsis
Declared in <nlohmann/json.hpp>
using object_t = map<basic_string<char>, basic_json, default_object_comparator_t, allocator<std::pair<basic_string<char> const, basic_json>>>;
Synopsis
Declared in <nlohmann/json.hpp>
using other_error = detail::other_error;
Synopsis
Declared in <nlohmann/json.hpp>
using out_of_range = detail::out_of_range;
Synopsis
Declared in <nlohmann/json.hpp>
using parse_error = detail::parse_error;
parser event types
Synopsis
Declared in <nlohmann/json.hpp>
using parse_event_t = detail::parse_event_t;
per-element parser callback type
Synopsis
Declared in <nlohmann/json.hpp>
using parser_callback_t = detail::parser_callback_t<basic_json>;
the type of an element pointer
Synopsis
Declared in <nlohmann/json.hpp>
using pointer = std::allocator_traits<allocator_type>::pointer;
the type of an element reference
Synopsis
Declared in <nlohmann/json.hpp>
using reference = value_type&;
a reverse iterator for a basic_json container
a type to represent container sizes
Synopsis
Declared in <nlohmann/json.hpp>
using size_type = std::size_t;
a type for a string
Synopsis
Declared in <nlohmann/json.hpp>
using string_t = basic_string<char>;
Synopsis
Declared in <nlohmann/json.hpp>
using type_error = detail::type_error;
Synopsis
Declared in <nlohmann/json.hpp>
using value_t = detail::value_t;
the type of elements in a basic_json container
Synopsis
Declared in <nlohmann/json.hpp>
using value_type = basic_json;
Construct from nullptr_t
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(std::nullptr_t value = nullptr) noexcept;
Parameters
Name |
Description |
value |
The object to construct from |
Construct from value_t
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(value_t const v);
Parameters
Name |
Description |
v |
The object to construct from |
Construct from basic_json
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(basic_json const& other);
Parameters
Name |
Description |
other |
The object to copy construct from |
Construct from basic_json
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(basic_json&& other) noexcept;
Parameters
Name |
Description |
other |
The object to move construct from |
create a JSON value from an existing one
Synopsis
Declared in <nlohmann/json.hpp>
template<typename BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value
basic_json(BasicJsonType const& val);
Parameters
Name |
Description |
val |
The object to copy construct from |
////////////////////////////////////
Synopsis
Declared in <nlohmann/json.hpp>
template<typename JsonRef>
requires detail::conjunction<detail::is_json_ref<JsonRef>,
std::is_same<typename JsonRef::value_type, basic_json>>::value
basic_json(JsonRef const& ref);
Parameters
Name |
Description |
ref |
The object to copy construct from |
create a JSON value from compatible types
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename CompatibleType,
typename U = detail::uncvref_t<CompatibleType>>
requires !detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value
basic_json(CompatibleType&& val) noexcept(noexcept(JSONSerializer<U, void>::to_json(std::declval<basic_json_t &>(), std::forward<CompatibleType>(val))));
Parameters
Name |
Description |
val |
The object to move construct from |
Constructor
Parameters
Name |
Description |
cnt |
The object to construct from |
val |
a class to store JSON values |
construct a JSON container given an iterator range
Synopsis
Declared in <nlohmann/json.hpp>
template<class InputIT>
requires std::is_same<InputIT, typename basic_json_t::iterator>::value ||
std::is_same<InputIT, typename basic_json_t::const_iterator>::value
basic_json(
InputIT first,
InputIT last);
Parameters
Name |
Description |
first |
The object to construct from |
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(
initializer_list_t init,
bool type_deduction = true,
value_t manual_type = value_t::array);
Destructor
Synopsis
Declared in <nlohmann/json.hpp>
~basic_json() noexcept;
Assignment operator
Synopsis
Declared in <nlohmann/json.hpp>
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);
Return Value
a class to store JSON values
Parameters
Name |
Description |
other |
The object to assign from |
Synopsis
Declared in <nlohmann/json.hpp>
reference
at(object_t::key_type const& key);
Synopsis
Declared in <nlohmann/json.hpp>
const_reference
at(object_t::key_type const& key) const;
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
reference
at(KeyType&& key);
Return Value
the type of an element reference
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_reference
at(KeyType&& key) const;
Return Value
the type of an element const reference
Synopsis
Declared in <nlohmann/json.hpp>
reference
back();
Synopsis
Declared in <nlohmann/json.hpp>
iterator
begin() noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
begin() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
cbegin() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
cend() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
void
clear() noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
bool
contains(json_pointer const& ptr) const;
Synopsis
Declared in <nlohmann/json.hpp>
bool
contains(object_t::key_type const& key) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<typename BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value
[[__deprecated__]]
bool
contains(nlohmann::json_pointer<BasicJsonType> const& ptr) const;
check the existence of an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
bool
contains(KeyType&& key) const;
Synopsis
Declared in <nlohmann/json.hpp>
size_type
count(object_t::key_type const& key) const;
returns the number of occurrences of a key in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
size_type
count(KeyType&& key) const;
Return Value
a type to represent container sizes
Synopsis
Declared in <nlohmann/json.hpp>
string_t
dump(
int const indent = -1,
char const indent_char = ' ',
bool const ensure_ascii = false,
error_handler_t const error_handler = error_handler_t::strict) const;
add an object to an object if key does not exist
Synopsis
Declared in <nlohmann/json.hpp>
template<class... Args>
std::pair<iterator, bool>
emplace(Args...&&... args);
add an object to an array
Synopsis
Declared in <nlohmann/json.hpp>
template<class... Args>
reference
emplace_back(Args...&&... args);
Return Value
the type of an element reference
Synopsis
Declared in <nlohmann/json.hpp>
bool
empty() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
iterator
end() noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
end() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
void
erase(size_type const idx);
Synopsis
Declared in <nlohmann/json.hpp>
size_type
erase(object_t::key_type const& key);
remove element given an iterator
Synopsis
Declared in <nlohmann/json.hpp>
template<class IteratorType>
requires std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value
IteratorType
erase(IteratorType pos);
remove element from a JSON object given a key
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
size_type
erase(KeyType&& key);
Return Value
a type to represent container sizes
remove elements given an iterator range
Synopsis
Declared in <nlohmann/json.hpp>
template<class IteratorType>
requires std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value
IteratorType
erase(
IteratorType first,
IteratorType last);
Synopsis
Declared in <nlohmann/json.hpp>
iterator
find(object_t::key_type const& key);
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
find(object_t::key_type const& key) const;
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_iterator
find(KeyType&& key) const;
Return Value
a const iterator for a basic_json container
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
iterator
find(KeyType&& key);
Return Value
an iterator for a basic_json container
Synopsis
Declared in <nlohmann/json.hpp>
basic_json
flatten() const;
Synopsis
Declared in <nlohmann/json.hpp>
reference
front();
get a pointer value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value
decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
get() noexcept;
Description
Explicit pointer access to the internally stored JSON value. No copies are made.
WARNING
The pointer becomes invalid if the underlying JSON object changes.
Constant.
{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}
Return Value
pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr
otherwise
get a (pointer) value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
constexpr
decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))
get() const noexcept(noexcept(std::declval<const basic_json_t &>().template get_impl<ValueType>(detail::priority_tag<4>{})));
Description
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.
Return Value
copy of the JSON value, converted to
Template Parameters
Name |
Description |
ValueTypeCV |
the provided value type |
ValueType |
the returned value type |
ValueType |
if necessary |
Synopsis
Declared in <nlohmann/json.hpp>
binary_t&
get_binary();
Synopsis
Declared in <nlohmann/json.hpp>
binary_t const&
get_binary() const;
get a pointer value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value&&
std::is_const<typename std::remove_pointer<PointerType>::type>::value
constexpr
decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
get_ptr() const noexcept;
get a pointer value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value
decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
get_ptr() noexcept;
get a reference value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ReferenceType>
requires std::is_reference<ReferenceType>::value
ReferenceType
get_ref();
get a reference value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ReferenceType>
requires std::is_reference<ReferenceType>::value&&
std::is_const<typename std::remove_reference<ReferenceType>::type>::value
ReferenceType
get_ref() const;
get a value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires !detail::is_basic_json<ValueType>::value&&
detail::has_from_json<basic_json_t, ValueType>::value
ValueType&
get_to(ValueType& v) const noexcept(noexcept(JSONSerializer<ValueType, void>::from_json(std::declval<const basic_json_t &>(), v)));
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires detail::is_basic_json<ValueType>::value
ValueType&
get_to(ValueType& v) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename T,
std::size_t N,
typename Array = T(&)[]>
requires detail::has_from_json<basic_json_t, Array>::value
Array
get_to(T(& v)[]) const noexcept(noexcept(JSONSerializer<Array, void>::from_json(std::declval<const basic_json_t &>(), v)));
Helper for insertion of an iterator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename... Args>
iterator
insert_iterator(
const_iterator pos,
Args...&&... args);
Description
NOTE
: This uses std::distance to support GCC 4.8, see https://github.com/nlohmann/json/pull/1257
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_array() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_binary() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_boolean() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_discarded() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_null() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_float() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_integer() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_unsigned() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_object() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_primitive() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_string() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_structured() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
size_type
max_size() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
void
merge_patch(basic_json const& apply_patch);
Addition assignment operator
Return Value
the type of an element reference
Parameters
Name |
Description |
init |
The right operand |
Addition assignment operator
Synopsis
Declared in <nlohmann/json.hpp>
reference
operator+=(object_t::value_type const& val);
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
Addition assignment operator
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
Addition assignment operator
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
reference
operator[](object_t::key_type key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Return Value
the type of an element reference
Parameters
Name |
Description |
idx |
The right operand |
Subscript operator
Return Value
the type of an element const reference
Parameters
Name |
Description |
idx |
The right operand |
Subscript operator
Return Value
the type of an element reference
Parameters
Name |
Description |
ptr |
The right operand |
Subscript operator
Return Value
the type of an element const reference
Parameters
Name |
Description |
ptr |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
const_reference
operator[](object_t::key_type const& key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Return Value
the type of an element const reference
Parameters
Name |
Description |
ptr |
The right operand |
Subscript operator
Return Value
the type of an element reference
Parameters
Name |
Description |
ptr |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
reference
operator[](KeyType&& key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_reference
operator[](KeyType&& key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
reference
operator[](T* key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
const_reference
operator[](T* key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
Synopsis
Declared in <nlohmann/json.hpp>
void
patch_inplace(basic_json const& json_patch);
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(object_t::value_type const& val);
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(basic_json const& val);
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(basic_json&& val);
Synopsis
Declared in <nlohmann/json.hpp>
size_type
size() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
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);
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(array_t& other);
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(binary_t& other);
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(object_t& other);
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(string_t& other);
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
value_t
type() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
[[__returns_nonnull__]]
char const*
type_name() const noexcept;
Synopsis
Declared in <nlohmann/json.hpp>
basic_json
unflatten() const;
Synopsis
Declared in <nlohmann/json.hpp>
void
update(
const_reference j,
bool merge_objects = false);
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<class ValueType>
requires detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
ValueType
value(
json_pointer const& ptr,
ValueType const& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<class ValueType>
requires !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
ValueType
value(
object_t::key_type const& key,
ValueType const& default_value) const;
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class ReturnType = value_return_type<ValueType>::type>
requires detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
ReturnType
value(
json_pointer const& ptr,
ValueType&& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class ReturnType = value_return_type<ValueType>::type>
requires !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
ReturnType
value(
object_t::key_type const& key,
ValueType&& default_value) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
[[__deprecated__]]
ValueType
value(
nlohmann::json_pointer<BasicJsonType> const& ptr,
ValueType const& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class KeyType>
requires 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
ValueType
value(
KeyType&& key,
ValueType const& default_value) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class BasicJsonType,
class ReturnType = value_return_type<ValueType>::type>
requires detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
[[__deprecated__]]
ReturnType
value(
nlohmann::json_pointer<BasicJsonType> const& ptr,
ValueType&& default_value) const;
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class KeyType,
class ReturnType = value_return_type<ValueType>::type>
requires 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
ReturnType
value(
KeyType&& key,
ValueType&& default_value) const;
get a value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires 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>>>,
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
detail::negation<std::is_same<ValueType, std::string_view>>,
#endif
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
detail::negation<std::is_same<ValueType, std::any>>,
#endif
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
>::value
operator ValueType() const;
Description
Implicit type conversion between the JSON value and a compatible value. The call is realized by calling get() const
.
Linear in the size of the JSON value.
{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}
Exceptions
Name |
Thrown on |
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 |
Return Value
copy of the JSON value, converted to type ValueType
Template Parameters
Name |
Description |
ValueType |
non-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 . |
Conversion to value_t
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
operator value_t() const noexcept;
Return Value
The object converted to value_t
comparison: equal
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ScalarType>
requires std::is_scalar_v<ScalarType>
bool
operator==(ScalarType rhs) const noexcept;
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Equality operator
Synopsis
Declared in <nlohmann/json.hpp>
bool
operator==(const_reference rhs) const noexcept;
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Inequality operator
Synopsis
Declared in <nlohmann/json.hpp>
bool
operator!=(const_reference rhs) const noexcept;
Return Value
true
if the objects are not equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
comparison: 3-way
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ScalarType>
requires std::is_scalar_v<ScalarType>
std::partial_ordering
operator<=>(ScalarType rhs) const noexcept;
Return Value
The relative order of the objects
Parameters
Name |
Description |
rhs |
The right operand |
Three-way comparison operator
Synopsis
Declared in <nlohmann/json.hpp>
std::partial_ordering
operator<=>(const_reference rhs) const noexcept;
Return Value
The relative order of the objects
Parameters
Name |
Description |
rhs |
The right operand |
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
bool
accept(
detail::span_input_adapter&& i,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
check if the input is valid JSON
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
static
bool
accept(
InputType&& i,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
check if the input is valid JSON
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
static
bool
accept(
IteratorType first,
IteratorType last,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
create a JSON value from an input in BJData format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_bjdata(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in BJData format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_bjdata(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_bson(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in BSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_bson(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in BSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_bson(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_bson(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_cbor(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
create a JSON value from an input in CBOR format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_cbor(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Return Value
a class to store JSON values
Parameters
Name |
Description |
tag_handler |
how to treat CBOR tags |
create a JSON value from an input in CBOR format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_cbor(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Return Value
a class to store JSON values
Parameters
Name |
Description |
tag_handler |
how to treat CBOR tags |
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_cbor(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_msgpack(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in MessagePack format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_msgpack(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in MessagePack format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_msgpack(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_msgpack(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_ubjson(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in UBJSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_ubjson(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in UBJSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_ubjson(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_ubjson(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
Synopsis
Declared in <nlohmann/json.hpp>
static
allocator_type
get_allocator();
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
meta();
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
parse(
detail::span_input_adapter&& i,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
deserialize from a compatible input
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
parse(
InputType&& i,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
Return Value
a class to store JSON values
Parameters
Name |
Description |
cb |
per-element parser callback type |
deserialize from a pair of character iterators
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
parse(
IteratorType first,
IteratorType last,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
Return Value
a class to store JSON values
Parameters
Name |
Description |
cb |
per-element parser callback type |
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<typename SAX>
[[__deprecated__, __nonnull__]]
static
bool
sax_parse(
detail::span_input_adapter&& i,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename InputType,
typename SAX>
[[__nonnull__]]
static
bool
sax_parse(
InputType&& i,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<
class IteratorType,
class SAX>
[[__nonnull__]]
static
bool
sax_parse(
IteratorType first,
IteratorType last,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_bjdata(
basic_json const& j,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bjdata(
basic_json const& j,
detail::output_adapter<uint8_t> o,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bjdata(
basic_json const& j,
detail::output_adapter<char> o,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_bson(basic_json const& j);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bson(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bson(
basic_json const& j,
detail::output_adapter<char> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_cbor(basic_json const& j);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_cbor(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_cbor(
basic_json const& j,
detail::output_adapter<char> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_msgpack(basic_json const& j);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_msgpack(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_msgpack(
basic_json const& j,
detail::output_adapter<char> o);
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_ubjson(
basic_json const& j,
bool const use_size = false,
bool const use_type = false);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_ubjson(
basic_json const& j,
detail::output_adapter<uint8_t> o,
bool const use_size = false,
bool const use_type = false);
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_ubjson(
basic_json const& j,
detail::output_adapter<char> o,
bool const use_size = false,
bool const use_type = false);
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<
template<
typename U,
typename V,
typename... Args> typename ObjectType = map,
template<
typename U,
typename... Args> typename ArrayType = vector,
class StringType = std::string,
class BooleanType = bool,
class NumberIntegerType = int64_t,
class NumberUnsignedType = uint64_t,
class NumberFloatType = double,
template<typename U> typename AllocatorType = allocator,
template<
typename T,
typename SFINAE = void> typename JSONSerializer = adl_serializer,
class BinaryType = std::vector<uint8_t>,
class CustomBaseClass = void>
class basic_json
: public nlohmann::detail::json_base_class<CustomBaseClass>
Base Classes
Name |
Description |
nlohmann::detail::json_base_class<CustomBaseClass> | |
Types
Member Functions
Name |
Description |
basic_json [constructor] | copy constructor |
basic_json [constructor] | move constructor |
basic_json [constructor] | create a null object |
basic_json [constructor] | create an empty value with a given type |
basic_json [constructor] | create a JSON value from an existing one |
basic_json [constructor] | //////////////////////////////////// |
basic_json [constructor] | create a JSON value from compatible types |
basic_json [constructor] | construct an array with count copies of given value |
basic_json [constructor] | construct a JSON container given an iterator range |
basic_json [constructor] | create a container (array or object) from an initializer list |
~basic_json [destructor] | destructor |
operator= | copy assignment |
at | access specified array element with bounds checking |
at | access specified array element with bounds checking |
at | access specified element via JSON Pointer |
at | access specified element via JSON Pointer |
at | access specified object element with bounds checking |
at | access specified object element with bounds checking |
at | |
at | |
at | access specified object element with bounds checking |
at | access specified object element with bounds checking |
back | access the last element |
back | access the last element |
begin | returns an iterator to the first element |
begin | returns an iterator to the first element |
cbegin | returns a const iterator to the first element |
cend | returns an iterator to one past the last element |
clear | clears the contents |
contains | check the existence of an element in a JSON object given a JSON pointer |
contains | check the existence of an element in a JSON object |
contains | |
contains | check the existence of an element in a JSON object |
count | returns the number of occurrences of a key in a JSON object |
count | returns the number of occurrences of a key in a JSON object |
crbegin | returns a const reverse iterator to the last element |
crend | returns a const reverse iterator to one before the first |
dump | serialization |
emplace | add an object to an object if key does not exist |
emplace_back | add an object to an array |
empty | checks whether the container is empty. |
end | returns an iterator to one past the last element |
end | returns an iterator to one past the last element |
erase | remove element from a JSON array given an index |
erase | remove element from a JSON object given a key |
erase | remove element given an iterator |
erase | remove element from a JSON object given a key |
erase | remove elements given an iterator range |
find | find an element in a JSON object |
find | find an element in a JSON object |
find | find an element in a JSON object |
find | find an element in a JSON object |
flatten | return flattened JSON value |
front | access the first element |
front | access the first element |
get | get a pointer value (explicit) |
get | get a (pointer) value (explicit) |
get_binary | get a binary value |
get_binary | get a binary value |
get_ptr | get a pointer value (implicit) |
get_ptr | get a pointer value (implicit) |
get_ref | get a reference value (implicit) |
get_ref | get a reference value (implicit) |
get_to | get a value (explicit) |
get_to | |
get_to | |
insert | inserts range of elements into object |
insert | inserts elements from initializer list into array |
insert | inserts element into array |
insert | inserts element into array |
insert | inserts range of elements into array |
insert | inserts copies of element into array |
insert_iterator | Helper for insertion of an iterator |
is_array | return whether value is an array |
is_binary | return whether value is a binary array |
is_boolean | return whether value is a boolean |
is_discarded | return whether value is discarded |
is_null | return whether value is null |
is_number | return whether value is a number |
is_number_float | return whether value is a floating-point number |
is_number_integer | return whether value is an integer number |
is_number_unsigned | return whether value is an unsigned integer number |
is_object | return whether value is an object |
is_primitive | return whether type is primitive |
is_string | return whether value is a string |
is_structured | return whether type is structured |
items | helper to access iterator member functions in range-based for |
items | helper to access iterator member functions in range-based for |
max_size | returns the maximum possible number of elements |
merge_patch | applies a JSON Merge Patch |
operator+= | add an object to an object |
operator+= | add an object to an array |
operator+= | add an object to an object |
operator+= | add an object to an array |
operator[] | access specified object element |
operator[] | access specified array element |
operator[] | access specified array element |
operator[] | access specified element via JSON Pointer |
operator[] | access specified element via JSON Pointer |
operator[] | access specified object element |
operator[] | Subscript operator |
operator[] | Subscript operator |
operator[] | access specified object element |
operator[] | access specified object element |
operator[] | Subscript operator |
operator[] | Subscript operator |
patch | applies a JSON patch to a copy of the current object |
patch_inplace | applies a JSON patch in-place without copying the object |
push_back | add an object to an object |
push_back | add an object to an array |
push_back | add an object to an object |
push_back | add an object to an array |
rbegin | returns an iterator to the reverse-beginning |
rbegin | returns an iterator to the reverse-beginning |
rend | returns an iterator to the reverse-end |
rend | returns an iterator to the reverse-end |
size | returns the number of elements |
swap | exchanges the values |
swap | exchanges the values |
swap | exchanges the values |
swap | exchanges the values |
swap | exchanges the values |
swap | exchanges the values |
type | return the type of the JSON value (explicit) |
type_name | return the type as string |
unflatten | unflatten a previously flattened JSON value |
update | updates a JSON object from another object, overwriting existing keys |
update | updates a JSON object from another object, overwriting existing keys |
value | access specified object element via JSON Pointer with default value |
value | access specified object element with default value |
value | access specified object element via JSON Pointer with default value |
value | access specified object element with default value |
value | |
value | access specified object element with default value |
value | |
value | access specified object element via JSON Pointer with default value |
operator ValueType | get a value (implicit) |
operator value_t | return the type of the JSON value (implicit) |
operator== | comparison: equal |
operator== | comparison: equal |
operator!= | comparison: not equal |
operator<=> | comparison: 3-way |
operator<=> | comparison: 3-way |
Static Member Functions
Name |
Description |
accept | |
accept | check if the input is valid JSON |
accept | check if the input is valid JSON |
array | explicitly create an array from an initializer list |
binary | explicitly create a binary array (without subtype) |
binary | explicitly create a binary array |
binary | explicitly create a binary array (with subtype) |
binary | explicitly create a binary array (with subtype) |
diff | creates a diff as a JSON patch |
from_bjdata | create a JSON value from an input in BJData format |
from_bjdata | create a JSON value from an input in BJData format |
from_bson | |
from_bson | create a JSON value from an input in BSON format |
from_bson | create a JSON value from an input in BSON format |
from_bson | |
from_cbor | |
from_cbor | create a JSON value from an input in CBOR format |
from_cbor | create a JSON value from an input in CBOR format |
from_cbor | |
from_msgpack | |
from_msgpack | create a JSON value from an input in MessagePack format |
from_msgpack | create a JSON value from an input in MessagePack format |
from_msgpack | |
from_ubjson | |
from_ubjson | create a JSON value from an input in UBJSON format |
from_ubjson | create a JSON value from an input in UBJSON format |
from_ubjson | |
get_allocator | returns the allocator associated with the container |
iterator_wrapper | wrapper to access iterator member functions in range-based for |
iterator_wrapper | wrapper to access iterator member functions in range-based for |
meta | returns version information on the library |
object | explicitly create an object from an initializer list |
parse | |
parse | deserialize from a compatible input |
parse | deserialize from a pair of character iterators |
sax_parse | generate SAX events |
sax_parse | generate SAX events |
sax_parse | generate SAX events |
to_bjdata | create a BJData serialization of a given JSON value |
to_bjdata | create a BJData serialization of a given JSON value |
to_bjdata | create a BJData serialization of a given JSON value |
to_bson | create a BSON serialization of a given JSON value |
to_bson | create a BSON serialization of a given JSON value |
to_bson | create a BSON serialization of a given JSON value |
to_cbor | create a CBOR serialization of a given JSON value |
to_cbor | create a CBOR serialization of a given JSON value |
to_cbor | create a CBOR serialization of a given JSON value |
to_msgpack | create a MessagePack serialization of a given JSON value |
to_msgpack | create a MessagePack serialization of a given JSON value |
to_msgpack | create a MessagePack serialization of a given JSON value |
to_ubjson | create a UBJSON serialization of a given JSON value |
to_ubjson | create a UBJSON serialization of a given JSON value |
to_ubjson | create a UBJSON serialization of a given JSON value |
Description
a class to store JSON values
@invariant The member variables @a m_value and @a m_type have the following
relationship:
- If `m_type == value_t::object`, then `m_value.object != nullptr`.
- If `m_type == value_t::array`, then `m_value.array != nullptr`.
- If `m_type == value_t::string`, then `m_value.string != nullptr`.
The invariants are checked by member function assert_invariant().
@note ObjectType trick from https://stackoverflow.com/a/9860911
the allocator type
Synopsis
Declared in <nlohmann/json.hpp>
using allocator_type = AllocatorType<basic_json>;
a type for an array
Synopsis
Declared in <nlohmann/json.hpp>
using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
a type for a packed binary type
how to encode BJData
Synopsis
Declared in <nlohmann/json.hpp>
using bjdata_version_t = detail::bjdata_version_t;
a type for a boolean
Synopsis
Declared in <nlohmann/json.hpp>
using boolean_t = BooleanType;
how to treat CBOR tags
Synopsis
Declared in <nlohmann/json.hpp>
using cbor_tag_handler_t = detail::cbor_tag_handler_t;
a const iterator for a basic_json container
the type of an element const pointer
Synopsis
Declared in <nlohmann/json.hpp>
using const_pointer = std::allocator_traits<allocator_type>::const_pointer;
the type of an element const reference
Synopsis
Declared in <nlohmann/json.hpp>
using const_reference = value_type const&;
a const reverse iterator for a basic_json container
Synopsis
Declared in <nlohmann/json.hpp>
using default_object_comparator_t = std::less;
a type to represent differences between iterators
Synopsis
Declared in <nlohmann/json.hpp>
using difference_type = std::ptrdiff_t;
how to treat decoding errors
Synopsis
Declared in <nlohmann/json.hpp>
using error_handler_t = detail::error_handler_t;
Classes to implement user-defined exceptions. @{
Synopsis
Declared in <nlohmann/json.hpp>
using exception = detail::exception;
helper type for initializer lists of basic_json values
Synopsis
Declared in <nlohmann/json.hpp>
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
Synopsis
Declared in <nlohmann/json.hpp>
using input_format_t = detail::input_format_t;
Synopsis
Declared in <nlohmann/json.hpp>
using invalid_iterator = detail::invalid_iterator;
an iterator for a basic_json container
SAX interface type, see nlohmann::json_sax
Synopsis
Declared in <nlohmann/json.hpp>
using json_sax_t = json_sax<basic_json>;
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename T,
typename SFINAE>
using json_serializer = JSONSerializer<T, SFINAE>;
a type for a number (floating-point)
Synopsis
Declared in <nlohmann/json.hpp>
using number_float_t = NumberFloatType;
a type for a number (integer)
Synopsis
Declared in <nlohmann/json.hpp>
using number_integer_t = NumberIntegerType;
a type for a number (unsigned)
Synopsis
Declared in <nlohmann/json.hpp>
using number_unsigned_t = NumberUnsignedType;
object key comparator type
Synopsis
Declared in <nlohmann/json.hpp>
using object_comparator_t = detail::actual_object_comparator_t<basic_json>;
a type for an object
Synopsis
Declared in <nlohmann/json.hpp>
using object_t = ObjectType<StringType, basic_json, default_object_comparator_t, AllocatorType<std::pair<StringType const, basic_json>>>;
Synopsis
Declared in <nlohmann/json.hpp>
using other_error = detail::other_error;
Synopsis
Declared in <nlohmann/json.hpp>
using out_of_range = detail::out_of_range;
Synopsis
Declared in <nlohmann/json.hpp>
using parse_error = detail::parse_error;
parser event types
Synopsis
Declared in <nlohmann/json.hpp>
using parse_event_t = detail::parse_event_t;
per-element parser callback type
Synopsis
Declared in <nlohmann/json.hpp>
using parser_callback_t = detail::parser_callback_t<basic_json>;
the type of an element pointer
Synopsis
Declared in <nlohmann/json.hpp>
using pointer = std::allocator_traits<allocator_type>::pointer;
the type of an element reference
Synopsis
Declared in <nlohmann/json.hpp>
using reference = value_type&;
a reverse iterator for a basic_json container
a type to represent container sizes
Synopsis
Declared in <nlohmann/json.hpp>
using size_type = std::size_t;
a type for a string
Synopsis
Declared in <nlohmann/json.hpp>
using string_t = StringType;
Synopsis
Declared in <nlohmann/json.hpp>
using type_error = detail::type_error;
Synopsis
Declared in <nlohmann/json.hpp>
using value_t = detail::value_t;
the type of elements in a basic_json container
Synopsis
Declared in <nlohmann/json.hpp>
using value_type = basic_json;
copy constructor
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(basic_json const& other);
Parameters
Name |
Description |
other |
The object to copy construct from |
move constructor
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(basic_json&& other) noexcept;
Parameters
Name |
Description |
other |
The object to move construct from |
create a null object
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(std::nullptr_t value = nullptr) noexcept;
Parameters
Name |
Description |
value |
The object to construct from |
create an empty value with a given type
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(value_t const v);
Parameters
Name |
Description |
v |
The object to construct from |
create a JSON value from an existing one
Synopsis
Declared in <nlohmann/json.hpp>
template<typename BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value
basic_json(BasicJsonType const& val);
Parameters
Name |
Description |
val |
The object to copy construct from |
////////////////////////////////////
Synopsis
Declared in <nlohmann/json.hpp>
template<typename JsonRef>
requires detail::conjunction<detail::is_json_ref<JsonRef>,
std::is_same<typename JsonRef::value_type, basic_json>>::value
basic_json(JsonRef const& ref);
Parameters
Name |
Description |
ref |
The object to copy construct from |
create a JSON value from compatible types
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename CompatibleType,
typename U = detail::uncvref_t<CompatibleType>>
requires !detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value
basic_json(CompatibleType&& val) noexcept(noexcept(JSONSerializer<U, void>::to_json(std::declval<basic_json_t &>(), std::forward<CompatibleType>(val))));
Parameters
Name |
Description |
val |
The object to move construct from |
construct an array with count copies of given value
Parameters
Name |
Description |
cnt |
The object to construct from |
val |
a class to store JSON values |
construct a JSON container given an iterator range
Synopsis
Declared in <nlohmann/json.hpp>
template<class InputIT>
requires std::is_same<InputIT, typename basic_json_t::iterator>::value ||
std::is_same<InputIT, typename basic_json_t::const_iterator>::value
basic_json(
InputIT first,
InputIT last);
Parameters
Name |
Description |
first |
The object to construct from |
create a container (array or object) from an initializer list
Synopsis
Declared in <nlohmann/json.hpp>
basic_json(
initializer_list_t init,
bool type_deduction = true,
value_t manual_type = value_t::array);
Parameters
Name |
Description |
init |
The object to construct from |
destructor
Synopsis
Declared in <nlohmann/json.hpp>
~basic_json() noexcept;
copy assignment
Synopsis
Declared in <nlohmann/json.hpp>
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);
Return Value
Reference to the current object
Parameters
Name |
Description |
other |
The object to assign from |
access specified array element with bounds checking
Return Value
the type of an element reference
Parameters
Name |
Description |
idx |
a type to represent container sizes |
access specified array element with bounds checking
Return Value
the type of an element const reference
Parameters
Name |
Description |
idx |
a type to represent container sizes |
access specified element via JSON Pointer
Return Value
the type of an element reference
access specified element via JSON Pointer
Return Value
the type of an element const reference
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
reference
at(object_t::key_type const& key);
Return Value
the type of an element reference
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
const_reference
at(object_t::key_type const& key) const;
Return Value
the type of an element const reference
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_reference
at(KeyType&& key) const;
Return Value
the type of an element const reference
access specified object element with bounds checking
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
reference
at(KeyType&& key);
Return Value
the type of an element reference
access the last element
Synopsis
Declared in <nlohmann/json.hpp>
reference
back();
Return Value
the type of an element reference
access the last element
Return Value
the type of an element const reference
returns an iterator to the first element
Synopsis
Declared in <nlohmann/json.hpp>
iterator
begin() noexcept;
Return Value
an iterator for a basic_json container
returns an iterator to the first element
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
begin() const noexcept;
Return Value
a const iterator for a basic_json container
returns a const iterator to the first element
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
cbegin() const noexcept;
Return Value
a const iterator for a basic_json container
returns an iterator to one past the last element
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
cend() const noexcept;
Return Value
a const iterator for a basic_json container
clears the contents
Synopsis
Declared in <nlohmann/json.hpp>
void
clear() noexcept;
check the existence of an element in a JSON object given a JSON pointer
Synopsis
Declared in <nlohmann/json.hpp>
bool
contains(json_pointer const& ptr) const;
check the existence of an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
bool
contains(object_t::key_type const& key) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<typename BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value
[[__deprecated__]]
bool
contains(nlohmann::json_pointer<BasicJsonType> const& ptr) const;
check the existence of an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
bool
contains(KeyType&& key) const;
returns the number of occurrences of a key in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
size_type
count(object_t::key_type const& key) const;
Return Value
a type to represent container sizes
returns the number of occurrences of a key in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
size_type
count(KeyType&& key) const;
Return Value
a type to represent container sizes
returns a const reverse iterator to the last element
Return Value
a const reverse iterator for a basic_json container
returns a const reverse iterator to one before the first
Return Value
a const reverse iterator for a basic_json container
serialization
Synopsis
Declared in <nlohmann/json.hpp>
string_t
dump(
int const indent = -1,
char const indent_char = ' ',
bool const ensure_ascii = false,
error_handler_t const error_handler = error_handler_t::strict) const;
Return Value
a type for a string
Parameters
Name |
Description |
error_handler |
how to treat decoding errors |
add an object to an object if key does not exist
Synopsis
Declared in <nlohmann/json.hpp>
template<class... Args>
std::pair<iterator, bool>
emplace(Args...&&... args);
add an object to an array
Synopsis
Declared in <nlohmann/json.hpp>
template<class... Args>
reference
emplace_back(Args...&&... args);
Return Value
the type of an element reference
checks whether the container is empty.
Synopsis
Declared in <nlohmann/json.hpp>
bool
empty() const noexcept;
returns an iterator to one past the last element
Synopsis
Declared in <nlohmann/json.hpp>
iterator
end() noexcept;
Return Value
an iterator for a basic_json container
returns an iterator to one past the last element
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
end() const noexcept;
Return Value
a const iterator for a basic_json container
remove element from a JSON array given an index
Synopsis
Declared in <nlohmann/json.hpp>
void
erase(size_type const idx);
Parameters
Name |
Description |
idx |
a type to represent container sizes |
remove element from a JSON object given a key
Synopsis
Declared in <nlohmann/json.hpp>
size_type
erase(object_t::key_type const& key);
Return Value
a type to represent container sizes
remove element given an iterator
Synopsis
Declared in <nlohmann/json.hpp>
template<class IteratorType>
requires std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value
IteratorType
erase(IteratorType pos);
remove element from a JSON object given a key
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
size_type
erase(KeyType&& key);
Return Value
a type to represent container sizes
remove elements given an iterator range
Synopsis
Declared in <nlohmann/json.hpp>
template<class IteratorType>
requires std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value
IteratorType
erase(
IteratorType first,
IteratorType last);
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
iterator
find(object_t::key_type const& key);
Return Value
an iterator for a basic_json container
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
const_iterator
find(object_t::key_type const& key) const;
Return Value
a const iterator for a basic_json container
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_iterator
find(KeyType&& key) const;
Return Value
a const iterator for a basic_json container
find an element in a JSON object
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
iterator
find(KeyType&& key);
Return Value
an iterator for a basic_json container
return flattened JSON value
Synopsis
Declared in <nlohmann/json.hpp>
basic_json
flatten() const;
Return Value
a class to store JSON values
access the first element
Synopsis
Declared in <nlohmann/json.hpp>
reference
front();
Return Value
the type of an element reference
access the first element
Return Value
the type of an element const reference
get a pointer value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value
decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
get() noexcept;
Description
Explicit pointer access to the internally stored JSON value. No copies are made.
WARNING
The pointer becomes invalid if the underlying JSON object changes.
Constant.
{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}
Return Value
pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr
otherwise
get a (pointer) value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
constexpr
decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))
get() const noexcept(noexcept(std::declval<const basic_json_t &>().template get_impl<ValueType>(detail::priority_tag<4>{})));
Description
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.
Return Value
copy of the JSON value, converted to
Template Parameters
Name |
Description |
ValueTypeCV |
the provided value type |
ValueType |
the returned value type |
ValueType |
if necessary |
get a binary value
Synopsis
Declared in <nlohmann/json.hpp>
binary_t&
get_binary();
Return Value
a type for a packed binary type
get a binary value
Synopsis
Declared in <nlohmann/json.hpp>
binary_t const&
get_binary() const;
Return Value
a type for a packed binary type
get a pointer value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value&&
std::is_const<typename std::remove_pointer<PointerType>::type>::value
constexpr
decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
get_ptr() const noexcept;
get a pointer value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename PointerType>
requires std::is_pointer<PointerType>::value
decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
get_ptr() noexcept;
get a reference value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ReferenceType>
requires std::is_reference<ReferenceType>::value
ReferenceType
get_ref();
get a reference value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ReferenceType>
requires std::is_reference<ReferenceType>::value&&
std::is_const<typename std::remove_reference<ReferenceType>::type>::value
ReferenceType
get_ref() const;
get a value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires !detail::is_basic_json<ValueType>::value&&
detail::has_from_json<basic_json_t, ValueType>::value
ValueType&
get_to(ValueType& v) const noexcept(noexcept(JSONSerializer<ValueType, void>::from_json(std::declval<const basic_json_t &>(), v)));
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires detail::is_basic_json<ValueType>::value
ValueType&
get_to(ValueType& v) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename T,
std::size_t N,
typename Array = T(&)[]>
requires detail::has_from_json<basic_json_t, Array>::value
Array
get_to(T(& v)[]) const noexcept(noexcept(JSONSerializer<Array, void>::from_json(std::declval<const basic_json_t &>(), v)));
inserts range of elements into object
Parameters
Name |
Description |
first |
a const iterator for a basic_json container |
last |
a const iterator for a basic_json container |
inserts elements from initializer list into array
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
ilist |
helper type for initializer lists of basic_json values |
inserts element into array
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
val |
a class to store JSON values |
inserts element into array
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
val |
a class to store JSON values |
inserts range of elements into array
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
first |
a const iterator for a basic_json container |
last |
a const iterator for a basic_json container |
inserts copies of element into array
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
cnt |
a type to represent container sizes |
val |
a class to store JSON values |
Helper for insertion of an iterator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename... Args>
iterator
insert_iterator(
const_iterator pos,
Args...&&... args);
Description
NOTE
: This uses std::distance to support GCC 4.8, see https://github.com/nlohmann/json/pull/1257
Return Value
an iterator for a basic_json container
Parameters
Name |
Description |
pos |
a const iterator for a basic_json container |
return whether value is an array
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_array() const noexcept;
return whether value is a binary array
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_binary() const noexcept;
return whether value is a boolean
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_boolean() const noexcept;
return whether value is discarded
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_discarded() const noexcept;
return whether value is null
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_null() const noexcept;
return whether value is a number
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number() const noexcept;
return whether value is a floating-point number
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_float() const noexcept;
return whether value is an integer number
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_integer() const noexcept;
return whether value is an unsigned integer number
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_number_unsigned() const noexcept;
return whether value is an object
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_object() const noexcept;
return whether type is primitive
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_primitive() const noexcept;
return whether value is a string
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_string() const noexcept;
return whether type is structured
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
bool
is_structured() const noexcept;
helper to access iterator member functions in range-based for
helper to access iterator member functions in range-based for
returns the maximum possible number of elements
Synopsis
Declared in <nlohmann/json.hpp>
size_type
max_size() const noexcept;
Return Value
a type to represent container sizes
applies a JSON Merge Patch
Synopsis
Declared in <nlohmann/json.hpp>
void
merge_patch(basic_json const& apply_patch);
Parameters
Name |
Description |
apply_patch |
a class to store JSON values |
add an object to an object
Return Value
the type of an element reference
Parameters
Name |
Description |
init |
The right operand |
add an object to an array
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
add an object to an object
Synopsis
Declared in <nlohmann/json.hpp>
reference
operator+=(object_t::value_type const& val);
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
add an object to an array
Return Value
the type of an element reference
Parameters
Name |
Description |
val |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
reference
operator[](object_t::key_type key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
access specified array element
Return Value
the type of an element reference
Parameters
Name |
Description |
idx |
The right operand |
access specified array element
Return Value
the type of an element const reference
Parameters
Name |
Description |
idx |
The right operand |
access specified element via JSON Pointer
Return Value
the type of an element reference
Parameters
Name |
Description |
ptr |
The right operand |
access specified element via JSON Pointer
Return Value
the type of an element const reference
Parameters
Name |
Description |
ptr |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
const_reference
operator[](object_t::key_type const& key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Return Value
the type of an element const reference
Parameters
Name |
Description |
ptr |
The right operand |
Subscript operator
Return Value
the type of an element reference
Parameters
Name |
Description |
ptr |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
reference
operator[](KeyType&& key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
access specified object element
Synopsis
Declared in <nlohmann/json.hpp>
template<class KeyType>
requires detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value
const_reference
operator[](KeyType&& key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
reference
operator[](T* key);
Return Value
the type of an element reference
Parameters
Name |
Description |
key |
The right operand |
Subscript operator
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
const_reference
operator[](T* key) const;
Return Value
the type of an element const reference
Parameters
Name |
Description |
key |
The right operand |
applies a JSON patch to a copy of the current object
Return Value
a class to store JSON values
Parameters
Name |
Description |
json_patch |
a class to store JSON values |
applies a JSON patch in-place without copying the object
Synopsis
Declared in <nlohmann/json.hpp>
void
patch_inplace(basic_json const& json_patch);
Parameters
Name |
Description |
json_patch |
a class to store JSON values |
add an object to an object
Parameters
Name |
Description |
init |
helper type for initializer lists of basic_json values |
add an object to an array
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(basic_json const& val);
Parameters
Name |
Description |
val |
a class to store JSON values |
add an object to an object
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(object_t::value_type const& val);
add an object to an array
Synopsis
Declared in <nlohmann/json.hpp>
void
push_back(basic_json&& val);
Parameters
Name |
Description |
val |
a class to store JSON values |
returns an iterator to the reverse-beginning
Return Value
a reverse iterator for a basic_json container
returns an iterator to the reverse-beginning
Return Value
a const reverse iterator for a basic_json container
returns an iterator to the reverse-end
Return Value
a reverse iterator for a basic_json container
returns an iterator to the reverse-end
Return Value
a const reverse iterator for a basic_json container
returns the number of elements
Synopsis
Declared in <nlohmann/json.hpp>
size_type
size() const noexcept;
Return Value
a type to represent container sizes
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
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);
Parameters
Name |
Description |
other |
the type of an element reference |
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(array_t& other);
Parameters
Name |
Description |
other |
a type for an array |
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(binary_t& other);
Parameters
Name |
Description |
other |
a type for a packed binary type |
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(binary_t::container_type& other);
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(object_t& other);
Parameters
Name |
Description |
other |
a type for an object |
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
void
swap(string_t& other);
Parameters
Name |
Description |
other |
a type for a string |
return the type of the JSON value (explicit)
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
value_t
type() const noexcept;
return the type as string
Synopsis
Declared in <nlohmann/json.hpp>
[[__returns_nonnull__]]
char const*
type_name() const noexcept;
unflatten a previously flattened JSON value
Synopsis
Declared in <nlohmann/json.hpp>
basic_json
unflatten() const;
Return Value
a class to store JSON values
updates a JSON object from another object, overwriting existing keys
Synopsis
Declared in <nlohmann/json.hpp>
void
update(
const_reference j,
bool merge_objects = false);
Parameters
Name |
Description |
j |
the type of an element const reference |
updates a JSON object from another object, overwriting existing keys
Parameters
Name |
Description |
first |
a const iterator for a basic_json container |
last |
a const iterator for a basic_json container |
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<class ValueType>
requires detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
ValueType
value(
json_pointer const& ptr,
ValueType const& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<class ValueType>
requires !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
ValueType
value(
object_t::key_type const& key,
ValueType const& default_value) const;
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class ReturnType = value_return_type<ValueType>::type>
requires detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
ReturnType
value(
json_pointer const& ptr,
ValueType&& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class ReturnType = value_return_type<ValueType>::type>
requires !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
ReturnType
value(
object_t::key_type const& key,
ValueType&& default_value) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class BasicJsonType>
requires detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ValueType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
[[__deprecated__]]
ValueType
value(
nlohmann::json_pointer<BasicJsonType> const& ptr,
ValueType const& default_value) const;
access specified object element with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class KeyType>
requires 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
ValueType
value(
KeyType&& key,
ValueType const& default_value) const;
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class BasicJsonType,
class ReturnType = value_return_type<ValueType>::type>
requires detail::is_basic_json<BasicJsonType>::value
&& detail::is_getable<basic_json_t, ReturnType>::value
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value
[[__deprecated__]]
ReturnType
value(
nlohmann::json_pointer<BasicJsonType> const& ptr,
ValueType&& default_value) const;
access specified object element via JSON Pointer with default value
Synopsis
Declared in <nlohmann/json.hpp>
template<
class ValueType,
class KeyType,
class ReturnType = value_return_type<ValueType>::type>
requires 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
ReturnType
value(
KeyType&& key,
ValueType&& default_value) const;
get a value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ValueType>
requires 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>>>,
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
detail::negation<std::is_same<ValueType, std::string_view>>,
#endif
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
detail::negation<std::is_same<ValueType, std::any>>,
#endif
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
>::value
operator ValueType() const;
Description
Implicit type conversion between the JSON value and a compatible value. The call is realized by calling get() const
.
Linear in the size of the JSON value.
{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}
Exceptions
Name |
Thrown on |
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 |
Return Value
copy of the JSON value, converted to type ValueType
Template Parameters
Name |
Description |
ValueType |
non-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 . |
return the type of the JSON value (implicit)
Synopsis
Declared in <nlohmann/json.hpp>
constexpr
operator value_t() const noexcept;
Return Value
The object converted to value_t
comparison: equal
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ScalarType>
requires std::is_scalar_v<ScalarType>
bool
operator==(ScalarType rhs) const noexcept;
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
comparison: equal
Synopsis
Declared in <nlohmann/json.hpp>
bool
operator==(const_reference rhs) const noexcept;
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
comparison: not equal
Synopsis
Declared in <nlohmann/json.hpp>
bool
operator!=(const_reference rhs) const noexcept;
Return Value
true
if the objects are not equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
comparison: 3-way
Synopsis
Declared in <nlohmann/json.hpp>
template<typename ScalarType>
requires std::is_scalar_v<ScalarType>
std::partial_ordering
operator<=>(ScalarType rhs) const noexcept;
Return Value
The relative order of the objects
Parameters
Name |
Description |
rhs |
The right operand |
comparison: 3-way
Synopsis
Declared in <nlohmann/json.hpp>
std::partial_ordering
operator<=>(const_reference rhs) const noexcept;
Return Value
The relative order of the objects
Parameters
Name |
Description |
rhs |
The right operand |
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
bool
accept(
detail::span_input_adapter&& i,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
check if the input is valid JSON
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
static
bool
accept(
InputType&& i,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
check if the input is valid JSON
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
static
bool
accept(
IteratorType first,
IteratorType last,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
explicitly create an array from an initializer list
Return Value
a class to store JSON values
Parameters
Name |
Description |
init |
helper type for initializer lists of basic_json values |
explicitly create a binary array (without subtype)
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
binary(binary_t::container_type const& init);
Return Value
a class to store JSON values
explicitly create a binary array
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
binary(binary_t::container_type&& init);
Return Value
a class to store JSON values
explicitly create a binary array (with subtype)
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
binary(
binary_t::container_type const& init,
binary_t::subtype_type subtype);
Return Value
a class to store JSON values
explicitly create a binary array (with subtype)
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
binary(
binary_t::container_type&& init,
binary_t::subtype_type subtype);
Return Value
a class to store JSON values
creates a diff as a JSON patch
Return Value
a class to store JSON values
Parameters
Name |
Description |
source |
a class to store JSON values |
target |
a class to store JSON values |
path |
a type for a string |
create a JSON value from an input in BJData format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_bjdata(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in BJData format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_bjdata(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_bson(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in BSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_bson(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in BSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_bson(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_bson(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_cbor(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
create a JSON value from an input in CBOR format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_cbor(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Return Value
a class to store JSON values
Parameters
Name |
Description |
tag_handler |
how to treat CBOR tags |
create a JSON value from an input in CBOR format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_cbor(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Return Value
a class to store JSON values
Parameters
Name |
Description |
tag_handler |
how to treat CBOR tags |
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_cbor(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true,
cbor_tag_handler_t const tag_handler = cbor_tag_handler_t::error);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_msgpack(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in MessagePack format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_msgpack(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in MessagePack format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_msgpack(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_msgpack(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_ubjson(
detail::span_input_adapter&& i,
bool const strict = true,
bool const allow_exceptions = true);
create a JSON value from an input in UBJSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
from_ubjson(
InputType&& i,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
create a JSON value from an input in UBJSON format
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
from_ubjson(
IteratorType first,
IteratorType last,
bool const strict = true,
bool const allow_exceptions = true);
Return Value
a class to store JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<typename T>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
from_ubjson(
T const* ptr,
std::size_t len,
bool const strict = true,
bool const allow_exceptions = true);
returns the allocator associated with the container
Synopsis
Declared in <nlohmann/json.hpp>
static
allocator_type
get_allocator();
Return Value
the allocator type
wrapper to access iterator member functions in range-based for
Parameters
Name |
Description |
ref |
the type of an element const reference |
wrapper to access iterator member functions in range-based for
Parameters
Name |
Description |
ref |
the type of an element reference |
returns version information on the library
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__]]
static
basic_json
meta();
Return Value
a class to store JSON values
explicitly create an object from an initializer list
Return Value
a class to store JSON values
Parameters
Name |
Description |
init |
helper type for initializer lists of basic_json values |
Synopsis
Declared in <nlohmann/json.hpp>
[[__warn_unused_result__, __deprecated__]]
static
basic_json
parse(
detail::span_input_adapter&& i,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
deserialize from a compatible input
Synopsis
Declared in <nlohmann/json.hpp>
template<typename InputType>
[[__warn_unused_result__]]
static
basic_json
parse(
InputType&& i,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
Return Value
a class to store JSON values
Parameters
Name |
Description |
cb |
per-element parser callback type |
deserialize from a pair of character iterators
Synopsis
Declared in <nlohmann/json.hpp>
template<typename IteratorType>
[[__warn_unused_result__]]
static
basic_json
parse(
IteratorType first,
IteratorType last,
parser_callback_t cb = nullptr,
bool const allow_exceptions = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
Return Value
a class to store JSON values
Parameters
Name |
Description |
cb |
per-element parser callback type |
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<typename SAX>
[[__deprecated__, __nonnull__]]
static
bool
sax_parse(
detail::span_input_adapter&& i,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<
typename InputType,
typename SAX>
[[__nonnull__]]
static
bool
sax_parse(
InputType&& i,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
generate SAX events
Synopsis
Declared in <nlohmann/json.hpp>
template<
class IteratorType,
class SAX>
[[__nonnull__]]
static
bool
sax_parse(
IteratorType first,
IteratorType last,
SAX* sax,
input_format_t format = input_format_t::json,
bool const strict = true,
bool const ignore_comments = false,
bool const ignore_trailing_commas = false);
create a BJData serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_bjdata(
basic_json const& j,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Parameters
Name |
Description |
j |
a class to store JSON values |
version |
how to encode BJData |
create a BJData serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bjdata(
basic_json const& j,
detail::output_adapter<uint8_t> o,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Parameters
Name |
Description |
j |
a class to store JSON values |
version |
how to encode BJData |
create a BJData serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bjdata(
basic_json const& j,
detail::output_adapter<char> o,
bool const use_size = false,
bool const use_type = false,
bjdata_version_t const version = bjdata_version_t::draft2);
Parameters
Name |
Description |
j |
a class to store JSON values |
version |
how to encode BJData |
create a BSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_bson(basic_json const& j);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a BSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bson(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a BSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_bson(
basic_json const& j,
detail::output_adapter<char> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a CBOR serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_cbor(basic_json const& j);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a CBOR serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_cbor(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a CBOR serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_cbor(
basic_json const& j,
detail::output_adapter<char> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a MessagePack serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_msgpack(basic_json const& j);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a MessagePack serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_msgpack(
basic_json const& j,
detail::output_adapter<uint8_t> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a MessagePack serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_msgpack(
basic_json const& j,
detail::output_adapter<char> o);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a UBJSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
std::vector<uint8_t>
to_ubjson(
basic_json const& j,
bool const use_size = false,
bool const use_type = false);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a UBJSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_ubjson(
basic_json const& j,
detail::output_adapter<uint8_t> o,
bool const use_size = false,
bool const use_type = false);
Parameters
Name |
Description |
j |
a class to store JSON values |
create a UBJSON serialization of a given JSON value
Synopsis
Declared in <nlohmann/json.hpp>
static
void
to_ubjson(
basic_json const& j,
detail::output_adapter<char> o,
bool const use_size = false,
bool const use_type = false);
Parameters
Name |
Description |
j |
a class to store JSON values |
an internal type for a backed binary type
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
template<typename BinaryType>
class byte_container_with_subtype
: public BinaryType
Base Classes
Name |
Description |
BinaryType | |
Types
Member Functions
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
using container_type = BinaryType;
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
using subtype_type = uint64_t;
Default constructor
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype() noexcept(noexcept(container_type()));
Construct from container_type
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(container_type const& b) noexcept(noexcept(container_type(b)));
Parameters
Name |
Description |
b |
The object to copy construct from |
Construct from container_type
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))));
Parameters
Name |
Description |
b |
The object to move construct from |
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(
container_type const& b,
subtype_type subtype_) noexcept(noexcept(container_type(b)));
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(
container_type&& b,
subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))));
clears the binary subtype
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
void
clear_subtype() noexcept;
return whether the value has a subtype
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
constexpr
bool
has_subtype() const noexcept;
sets the binary subtype
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
void
set_subtype(subtype_type subtype_) noexcept;
return the binary subtype
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
constexpr
subtype_type
subtype() const noexcept;
Equality operator
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Inequality operator
Return Value
true
if the objects are not equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
template<>
class byte_container_with_subtype<vector<unsigned char>>
: public vector<unsigned char>
Base Classes
Name |
Description |
vector<unsigned char> | |
Types
Member Functions
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
using container_type = vector<unsigned char>;
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
using subtype_type = uint64_t;
Constructors
Default constructor
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype() noexcept(noexcept(container_type()));
Construct from container_type
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(container_type const& b) noexcept(noexcept(container_type(b)));
Parameters
Name |
Description |
b |
The object to copy construct from |
Construct from container_type
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))));
Parameters
Name |
Description |
b |
The object to move construct from |
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(
container_type const& b,
subtype_type subtype_) noexcept(noexcept(container_type(b)));
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
byte_container_with_subtype(
container_type&& b,
subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))));
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
void
clear_subtype() noexcept;
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
constexpr
bool
has_subtype() const noexcept;
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
void
set_subtype(subtype_type subtype_) noexcept;
Synopsis
Declared in <nlohmann/byte_container_with_subtype.hpp>
constexpr
subtype_type
subtype() const noexcept;
Equality operator
Return Value
true
if the objects are equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Inequality operator
Return Value
true
if the objects are not equal, false
otherwise
Parameters
Name |
Description |
rhs |
The right operand |
Synopsis
Declared in <nlohmann/json.hpp>
template<typename>
class json_pointer;
JSON Pointer defines a string syntax for identifying a specific value within a JSON document
Synopsis
Declared in <nlohmann/json_fwd.hpp>
template<typename RefStringType>
class json_pointer;
Friends
Name |
Description |
operator/ |
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer |
operator/ |
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer |
operator/ |
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer |
operator<< |
write string representation of the JSON pointer to stream |
json_pointer |
JSON Pointer defines a string syntax for identifying a specific value within a JSON document |
basic_json |
a class to store JSON values |
|===
a minimal map-like container that preserves insertion order
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<
class Key,
class T,
class IgnoredLess,
class Allocator>
struct ordered_map
: std::vector<std::pair<Key const, T>, Allocator>
Base Classes
Name |
Description |
std::vector<std::pair<Key const, T>, Allocator> | |
Types
Member Functions
Description
ordered_map: a minimal map-like container that preserves insertion order for use within nlohmann::basic_json<ordered_map>
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using Container = std::vector<std::pair<Key const, T>, Allocator>;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using const_iterator = Container::const_iterator;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using iterator = Container::iterator;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using key_compare = std::equal_to;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using key_type = Key;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using mapped_type = T;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<typename InputIt>
using require_input_iter = void;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using size_type = Container::size_type;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
using value_type = Container::value_type;
Constructors
Synopses
Declared in <nlohmann/ordered_map.hpp>
Default constructor
ordered_map() noexcept(noexcept(Container()));
» more...
Construct from Allocator
explicit
ordered_map(Allocator const& alloc) noexcept(noexcept(Container(alloc)));
» more...
ordered_map(
std::initializer_list<value_type> init,
Allocator const& alloc = Allocator());
» more...
template<class It>
ordered_map(
It first,
It last,
Allocator const& alloc = Allocator());
» more...
Default constructor
Synopsis
Declared in <nlohmann/ordered_map.hpp>
ordered_map() noexcept(noexcept(Container()));
Construct from Allocator
Synopsis
Declared in <nlohmann/ordered_map.hpp>
explicit
ordered_map(Allocator const& alloc) noexcept(noexcept(Container(alloc)));
Parameters
Name |
Description |
alloc |
The object to copy construct from |
Synopsis
Declared in <nlohmann/ordered_map.hpp>
ordered_map(
std::initializer_list<value_type> init,
Allocator const& alloc = Allocator());
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class It>
ordered_map(
It first,
It last,
Allocator const& alloc = Allocator());
Synopses
Declared in <nlohmann/ordered_map.hpp>
T&
at(key_type const& key);
» more...
T const&
at(key_type const& key) const;
» more...
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T const&
at(KeyType&& key) const;
» more...
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T&
at(KeyType&& key);
» more...
Synopsis
Declared in <nlohmann/ordered_map.hpp>
T&
at(key_type const& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
T const&
at(key_type const& key) const;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T const&
at(KeyType&& key) const;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T&
at(KeyType&& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
size_type
count(key_type const& key) const;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
size_type
count(KeyType&& key) const;
Synopses
Declared in <nlohmann/ordered_map.hpp>
std::pair<iterator, bool>
emplace(
key_type const& key,
T&& t);
» more...
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
std::pair<iterator, bool>
emplace(
KeyType&& key,
T&& t);
» more...
Synopsis
Declared in <nlohmann/ordered_map.hpp>
std::pair<iterator, bool>
emplace(
key_type const& key,
T&& t);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
std::pair<iterator, bool>
emplace(
KeyType&& key,
T&& t);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
size_type
erase(key_type const& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
size_type
erase(KeyType&& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
iterator
find(key_type const& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
iterator
find(KeyType&& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
std::pair<iterator, bool>
insert(value_type const& value);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
std::pair<iterator, bool>
insert(value_type&& value);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<
typename InputIt,
typename = require_input_iter<InputIt>>
void
insert(
InputIt first,
InputIt last);
Subscript operators
Synopsis
Declared in <nlohmann/ordered_map.hpp>
T&
operator[](key_type const& key);
Synopsis
Declared in <nlohmann/ordered_map.hpp>
T const&
operator[](key_type const& key) const;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T const&
operator[](KeyType&& key) const;
Synopsis
Declared in <nlohmann/ordered_map.hpp>
template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T&
operator[](KeyType&& key);
Synopsis
Declared in <nlohmann/json.hpp>
[[__nonnull__]]
nlohmann::json
Unnamed function(
char const* s,
std::size_t n);
Right shift operators
deserialize from stream
Synopsis
Declared in <nlohmann/json.hpp>
std::istream&
operator>>(
std::istream& i,
basic_json& j);
Parameters
Name |
Description |
i |
The left operand |
j |
The right operand |
deserialize from stream
Synopsis
Declared in <nlohmann/json.hpp>
std::istream&
operator>>(
std::istream& i,
basic_json& j);
Parameters
Name |
Description |
i |
The left operand |
j |
The right operand |
serialize to stream
Synopsis
Declared in <nlohmann/json.hpp>
[[__deprecated__]]
std::ostream&
operator>>(
basic_json const& j,
std::ostream& o);
Parameters
Name |
Description |
j |
The left operand |
o |
The right operand |
serialize to stream
Synopsis
Declared in <nlohmann/json.hpp>
[[__deprecated__]]
std::ostream&
operator>>(
basic_json const& j,
std::ostream& o);
Parameters
Name |
Description |
j |
The left operand |
o |
The right operand |
exchanges the values
Synopses
Declared in <nlohmann/json.hpp>
exchanges the values
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);
» more...
exchanges the values
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);
» more...
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
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);
Parameters
Name |
Description |
left |
the type of an element reference |
right |
the type of an element reference |
exchanges the values
Synopsis
Declared in <nlohmann/json.hpp>
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);
Parameters
Name |
Description |
left |
the type of an element reference |
right |
the type of an element reference |
user-defined to_string function for JSON values
Synopsis
Declared in <nlohmann/json.hpp>
template<
template<
typename,
typename,
typename...> typename ObjectType,
template<
typename,
typename...> typename ArrayType,
class StringType,
class BooleanType,
class NumberIntegerType,
class NumberUnsignedType,
class NumberFloatType,
template<typename> typename AllocatorType,
template<
typename,
typename = void> typename JSONSerializer,
class BinaryType,
class CustomBaseClass>
std::string
to_string(basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass> const& j);
Parameters
Name |
Description |
j |
a class to store JSON values |
Left shift operators
deserialize from stream
Synopsis
Declared in <nlohmann/json.hpp>
[[__deprecated__]]
std::istream&
operator<<(
basic_json& j,
std::istream& i);
Parameters
Name |
Description |
j |
The left operand |
i |
The right operand |
serialize to stream
Synopsis
Declared in <nlohmann/json.hpp>
std::ostream&
operator<<(
std::ostream& o,
basic_json const& j);
Return Value
Reference to the current output stream
Parameters
Name |
Description |
o |
An output stream |
j |
The object to output |
deserialize from stream
Synopsis
Declared in <nlohmann/json.hpp>
[[__deprecated__]]
std::istream&
operator<<(
basic_json& j,
std::istream& i);
Parameters
Name |
Description |
j |
The left operand |
i |
The right operand |
serialize to stream
Synopsis
Declared in <nlohmann/json.hpp>
std::ostream&
operator<<(
std::ostream& o,
basic_json const& j);
Return Value
Reference to the current output stream
Parameters
Name |
Description |
o |
An output stream |
j |
The object to output |
Synopsis
Declared in <nlohmann/json.hpp>
using nlohmann::literals::json_literals::;
Synopsis
Declared in <nlohmann/json.hpp>
using nlohmann::literals::json_literals::;