|
|
|
@@ -612,100 +612,210 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// constructor for rvalue binary arrays (internal type)
|
|
|
|
|
json_value(binary_t&& value) : binary(create<binary_t>(std::move(value))) {}
|
|
|
|
|
|
|
|
|
|
void destroy(value_t t)
|
|
|
|
|
private:
|
|
|
|
|
// raw, allocation-free transfer of m_data from src to dst: no
|
|
|
|
|
// set_parents()/assert_invariant() (the former is O(#children) per
|
|
|
|
|
// call under JSON_DIAGNOSTICS, which would make the walk below
|
|
|
|
|
// quadratic); dst takes ownership, src is left as value_t::null.
|
|
|
|
|
static void take(basic_json& dst, basic_json& src) noexcept
|
|
|
|
|
{
|
|
|
|
|
dst.m_data.m_type = src.m_data.m_type;
|
|
|
|
|
dst.m_data.m_value = src.m_data.m_value;
|
|
|
|
|
src.m_data.m_type = value_t::null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// true if v is not an array/object, or is an already-empty one
|
|
|
|
|
static bool has_no_children(const basic_json& v) noexcept
|
|
|
|
|
{
|
|
|
|
|
switch (v.m_data.m_type)
|
|
|
|
|
{
|
|
|
|
|
case value_t::array:
|
|
|
|
|
return v.m_data.m_value.array->empty();
|
|
|
|
|
case value_t::object:
|
|
|
|
|
return v.m_data.m_value.object->empty();
|
|
|
|
|
default:
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static basic_json& last_child(basic_json& v)
|
|
|
|
|
{
|
|
|
|
|
if (v.m_data.m_type == value_t::array)
|
|
|
|
|
{
|
|
|
|
|
return v.m_data.m_value.array->back();
|
|
|
|
|
}
|
|
|
|
|
JSON_ASSERT(v.m_data.m_type == value_t::object);
|
|
|
|
|
return v.m_data.m_value.object->rbegin()->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// removes the last child of a non-empty array/object v; this never
|
|
|
|
|
// allocates, and since it is only ever called when that child is a
|
|
|
|
|
// scalar or an already-empty array/object, destroying it never
|
|
|
|
|
// recurses more than one level deep (see destroy() below)
|
|
|
|
|
static void pop_last_child(basic_json& v)
|
|
|
|
|
{
|
|
|
|
|
if (v.m_data.m_type == value_t::array)
|
|
|
|
|
{
|
|
|
|
|
v.m_data.m_value.array->pop_back();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
JSON_ASSERT(v.m_data.m_type == value_t::object);
|
|
|
|
|
// erase() needs a forward iterator, so std::prev(end()) is
|
|
|
|
|
// used here rather than rbegin() (see last_child() above)
|
|
|
|
|
v.m_data.m_value.object->erase(std::prev(v.m_data.m_value.object->end()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// deallocates the (already empty) array/object held by v; this is
|
|
|
|
|
// the same allocator-based free the old recursive implementation
|
|
|
|
|
// used, just factored out so every level of the walk in destroy()
|
|
|
|
|
// can share it
|
|
|
|
|
static void free_container(basic_json& v) noexcept
|
|
|
|
|
{
|
|
|
|
|
if (v.m_data.m_type == value_t::array)
|
|
|
|
|
{
|
|
|
|
|
JSON_ASSERT(v.m_data.m_value.array->empty());
|
|
|
|
|
AllocatorType<array_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, v.m_data.m_value.array);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, v.m_data.m_value.array, 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
JSON_ASSERT(v.m_data.m_type == value_t::object);
|
|
|
|
|
JSON_ASSERT(v.m_data.m_value.object->empty());
|
|
|
|
|
AllocatorType<object_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, v.m_data.m_value.object);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, v.m_data.m_value.object, 1);
|
|
|
|
|
}
|
|
|
|
|
v.m_data.m_type = value_t::null; // avoid a double free if v is later destructed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void destroy_string() noexcept
|
|
|
|
|
{
|
|
|
|
|
if (string == nullptr)
|
|
|
|
|
{
|
|
|
|
|
// not initialized (e.g., due to exception in the ctor)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllocatorType<string_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void destroy_binary() noexcept
|
|
|
|
|
{
|
|
|
|
|
if (binary == nullptr)
|
|
|
|
|
{
|
|
|
|
|
// not initialized (e.g., due to exception in the ctor)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AllocatorType<binary_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// t must be value_t::array or value_t::object
|
|
|
|
|
void destroy_container(value_t t) noexcept
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
(t == value_t::object && object == nullptr) ||
|
|
|
|
|
(t == value_t::array && array == nullptr) ||
|
|
|
|
|
(t == value_t::string && string == nullptr) ||
|
|
|
|
|
(t == value_t::binary && binary == nullptr)
|
|
|
|
|
(t == value_t::array && array == nullptr)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// not initialized (e.g., due to exception in the ctor)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (t == value_t::array || t == value_t::object)
|
|
|
|
|
|
|
|
|
|
// Destroy the tree without recursing per nesting level and
|
|
|
|
|
// without any heap allocation: a heap-allocated flattening
|
|
|
|
|
// stack (the previous implementation) can itself throw
|
|
|
|
|
// bad_alloc, which would escape this noexcept destructor and
|
|
|
|
|
// terminate the program (#5135).
|
|
|
|
|
//
|
|
|
|
|
// Instead, walk down the "last child" chain, reversing links
|
|
|
|
|
// as we go: cur is the container currently being emptied,
|
|
|
|
|
// and prev is its parent (value_t::null when there is none).
|
|
|
|
|
// Each parent's last child slot doubles as storage for that
|
|
|
|
|
// parent's own parent link while we are below it, so no
|
|
|
|
|
// extra memory is needed. We only ever remove a child once
|
|
|
|
|
// it is a scalar or an empty array/object, which neither
|
|
|
|
|
// allocates nor recurses more than one level deep.
|
|
|
|
|
//
|
|
|
|
|
// This json_value is not itself a basic_json, so the
|
|
|
|
|
// top-level container is first moved into a local stand-in
|
|
|
|
|
// ("cur"); a default-constructed basic_json has a null
|
|
|
|
|
// pointer in its m_value (see data::m_value's initializer),
|
|
|
|
|
// so swapping it with *this leaves this union's own pointer
|
|
|
|
|
// null, and it is never looked at or freed a second time.
|
|
|
|
|
basic_json cur;
|
|
|
|
|
cur.m_data.m_type = t;
|
|
|
|
|
using std::swap;
|
|
|
|
|
swap(cur.m_data.m_value, *this);
|
|
|
|
|
|
|
|
|
|
basic_json prev; // value_t::null: no parent
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
// flatten the current json_value to a heap-allocated stack
|
|
|
|
|
std::vector<basic_json> stack;
|
|
|
|
|
|
|
|
|
|
// move the top-level items to stack
|
|
|
|
|
if (t == value_t::array)
|
|
|
|
|
if (has_no_children(cur))
|
|
|
|
|
{
|
|
|
|
|
stack.reserve(array->size());
|
|
|
|
|
std::move(array->begin(), array->end(), std::back_inserter(stack));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stack.reserve(object->size());
|
|
|
|
|
for (auto&& it : *object)
|
|
|
|
|
if (prev.m_data.m_type == value_t::null)
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(std::move(it.second));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (!stack.empty())
|
|
|
|
|
{
|
|
|
|
|
// move the last item to a local variable to be processed
|
|
|
|
|
basic_json current_item(std::move(stack.back()));
|
|
|
|
|
stack.pop_back();
|
|
|
|
|
|
|
|
|
|
// if current_item is array/object, move
|
|
|
|
|
// its children to the stack to be processed later
|
|
|
|
|
if (current_item.is_array())
|
|
|
|
|
{
|
|
|
|
|
std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
|
|
|
|
|
|
|
|
|
|
current_item.m_data.m_value.array->clear();
|
|
|
|
|
}
|
|
|
|
|
else if (current_item.is_object())
|
|
|
|
|
{
|
|
|
|
|
for (auto&& it : *current_item.m_data.m_value.object)
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(std::move(it.second));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_item.m_data.m_value.object->clear();
|
|
|
|
|
free_container(cur);
|
|
|
|
|
return; // back at the top with nothing left to do
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// it's now safe that current_item gets destructed
|
|
|
|
|
// since it doesn't have any children
|
|
|
|
|
// ascend: detach the grandparent link from prev's
|
|
|
|
|
// last slot, drop that (now null) slot, free cur
|
|
|
|
|
// (it is empty), then move up one level
|
|
|
|
|
basic_json gp;
|
|
|
|
|
take(gp, last_child(prev));
|
|
|
|
|
pop_last_child(prev);
|
|
|
|
|
|
|
|
|
|
free_container(cur);
|
|
|
|
|
|
|
|
|
|
take(cur, prev);
|
|
|
|
|
take(prev, gp);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
basic_json& cur_last_ref = last_child(cur);
|
|
|
|
|
|
|
|
|
|
if (has_no_children(cur_last_ref))
|
|
|
|
|
{
|
|
|
|
|
// scalar, or already-empty array/object
|
|
|
|
|
pop_last_child(cur);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// descend into the non-empty last child, reversing the
|
|
|
|
|
// link: its slot takes over prev, and the child becomes
|
|
|
|
|
// the new cur
|
|
|
|
|
basic_json tmp;
|
|
|
|
|
take(tmp, cur_last_ref);
|
|
|
|
|
take(cur_last_ref, prev);
|
|
|
|
|
take(prev, cur);
|
|
|
|
|
take(cur, tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void destroy(value_t t)
|
|
|
|
|
{
|
|
|
|
|
switch (t)
|
|
|
|
|
{
|
|
|
|
|
case value_t::object:
|
|
|
|
|
{
|
|
|
|
|
AllocatorType<object_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case value_t::array:
|
|
|
|
|
{
|
|
|
|
|
AllocatorType<array_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case value_t::string:
|
|
|
|
|
{
|
|
|
|
|
AllocatorType<string_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
|
|
|
|
|
destroy_string();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case value_t::binary:
|
|
|
|
|
{
|
|
|
|
|
AllocatorType<binary_t> alloc;
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
|
|
|
|
|
std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
|
|
|
|
|
destroy_binary();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case value_t::object:
|
|
|
|
|
case value_t::array:
|
|
|
|
|
destroy_container(t);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case value_t::null:
|
|
|
|
|
case value_t::boolean:
|
|
|
|
@@ -714,9 +824,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
case value_t::number_float:
|
|
|
|
|
case value_t::discarded:
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@@ -3492,9 +3600,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
ValueType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, const ValueType& default_value) const
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return value(ptr.convert(), default_value);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
|
|
|
|
|
detail::enable_if_t <
|
|
|
|
@@ -3503,9 +3615,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
&& !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int > = 0 >
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
ReturnType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr, ValueType && default_value) const
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return value(ptr.convert(), std::forward<ValueType>(default_value));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief access the first element
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/front/
|
|
|
|
@@ -3863,9 +3979,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
bool contains(const typename ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ptr.contains(this);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
|
@@ -3976,9 +4096,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// that is, replace `json::iterator_wrapper(j)` with `j.items()`.
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
|
|
|
|
|
static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ref.items();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief wrapper to access iterator member functions in range-based for
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/items/
|
|
|
|
@@ -3987,9 +4111,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// that is, replace `json::iterator_wrapper(j)` with `j.items()`.
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
|
|
|
|
|
static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ref.items();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief helper to access iterator member functions in range-based for
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/items/
|
|
|
|
@@ -5078,7 +5206,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_le/
|
|
|
|
|
template<typename ScalarType>
|
|
|
|
|
requires std::is_scalar_v<ScalarType>
|
|
|
|
|
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) <= rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5087,7 +5215,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ge/
|
|
|
|
|
template<typename ScalarType>
|
|
|
|
|
requires std::is_scalar_v<ScalarType>
|
|
|
|
|
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) >= rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5108,11 +5236,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The friend comparisons with a scalar name the JSON type via decltype of
|
|
|
|
|
// their parameter in noexcept, because older MSVC versions do not see the
|
|
|
|
|
// class scope there: MSVC 2015 and 2017 take basic_json as the template,
|
|
|
|
|
// and MSVC 2019 16.0 rejects member types and template parameters.
|
|
|
|
|
|
|
|
|
|
/// @brief comparison: equal
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs == basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5121,7 +5254,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) == rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5137,7 +5270,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ne/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs != basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5146,7 +5279,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ne/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) != rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5166,7 +5299,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_lt/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs < basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5175,7 +5308,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_lt/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) < rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5195,7 +5328,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_le/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs <= basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5204,7 +5337,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_le/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) <= rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5225,7 +5358,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_gt/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs > basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5234,7 +5367,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_gt/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) > rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5254,7 +5387,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ge/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(lhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return lhs >= basic_json(rhs);
|
|
|
|
|
}
|
|
|
|
@@ -5263,7 +5396,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator_ge/
|
|
|
|
|
template<typename ScalarType, typename std::enable_if<
|
|
|
|
|
std::is_scalar<ScalarType>::value, int>::type = 0>
|
|
|
|
|
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<basic_json, ScalarType>::value)
|
|
|
|
|
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept(std::is_nothrow_constructible<detail::uncvref_t<decltype(rhs)>, ScalarType>::value)
|
|
|
|
|
{
|
|
|
|
|
return basic_json(lhs) >= rhs;
|
|
|
|
|
}
|
|
|
|
@@ -5299,6 +5432,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
// the deleted version is a function template after the class, because
|
|
|
|
|
// GCC < 5 and Clang < 10 reject deleted friend functions in class templates
|
|
|
|
|
/// @brief serialize to stream
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/operator_ltlt/
|
|
|
|
|
/// @deprecated This function is deprecated since 3.0.0 and will be removed in
|
|
|
|
@@ -5310,6 +5446,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
{
|
|
|
|
|
return o << j;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif // JSON_NO_IO
|
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
|
@@ -5361,12 +5498,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
const bool allow_exceptions = true,
|
|
|
|
|
const bool ignore_comments = false,
|
|
|
|
|
const bool ignore_trailing_commas = false)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
basic_json result;
|
|
|
|
|
auto p = parser(i.get(), std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
|
|
|
|
|
p.parse(true, result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief check if the input is valid JSON
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/accept/
|
|
|
|
@@ -5396,9 +5537,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
static bool accept(detail::span_input_adapter&& i,
|
|
|
|
|
const bool ignore_comments = false,
|
|
|
|
|
const bool ignore_trailing_commas = false)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return parser(i.get(), nullptr, false, ignore_comments, ignore_trailing_commas, true).accept(true);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief generate SAX events
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/sax_parse/
|
|
|
|
@@ -5459,6 +5604,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool ignore_comments = false,
|
|
|
|
|
const bool ignore_trailing_commas = false)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
auto ia = i.get();
|
|
|
|
|
return format == input_format_t::json
|
|
|
|
@@ -5467,10 +5615,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
// NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
|
|
|
|
|
: detail::binary_reader<basic_json, decltype(ia), SAX, true>(std::move(ia), format).sax_parse(sax, strict);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(__clang__)
|
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef JSON_NO_IO
|
|
|
|
|
#if !JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
// the deleted version is a function template after the class, because
|
|
|
|
|
// GCC < 5 and Clang < 10 reject deleted friend functions in class templates
|
|
|
|
|
/// @brief deserialize from stream
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/operator_gtgt/
|
|
|
|
|
/// @deprecated This stream operator is deprecated since 3.0.0 and will be removed in
|
|
|
|
@@ -5482,6 +5634,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
{
|
|
|
|
|
return operator>>(i, j);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief deserialize from stream
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/operator_gtgt/
|
|
|
|
@@ -5829,9 +5982,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true,
|
|
|
|
|
const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
|
|
|
|
@@ -5839,9 +5996,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true,
|
|
|
|
|
const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_binary_impl(i.get(), input_format_t::cbor, strict, allow_exceptions, error_handler_t::keep, tag_handler);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief create a JSON value from an input in MessagePack format
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/from_msgpack/
|
|
|
|
@@ -5874,18 +6035,26 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
static basic_json from_msgpack(const T* ptr, std::size_t len,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
|
|
|
|
|
static basic_json from_msgpack(detail::span_input_adapter&& i,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_binary_impl(i.get(), input_format_t::msgpack, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief create a JSON value from an input in UBJSON format
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/from_ubjson/
|
|
|
|
@@ -5918,18 +6087,26 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
static basic_json from_ubjson(const T* ptr, std::size_t len,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
|
|
|
|
|
static basic_json from_ubjson(detail::span_input_adapter&& i,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_binary_impl(i.get(), input_format_t::ubjson, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief create a JSON value from an input in BJData format
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/
|
|
|
|
@@ -5956,6 +6133,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
return from_binary_impl(detail::input_adapter(std::move(first), std::move(last)), input_format_t::bjdata, strict, allow_exceptions, error_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.13.0, from_bjdata(ptr, ptr + len))
|
|
|
|
|
static basic_json from_bjdata(const T* ptr, std::size_t len,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_bjdata(ptr, ptr + len, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief create a JSON value from an input in BON8 format
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bon8/
|
|
|
|
|
template<typename InputType>
|
|
|
|
@@ -5979,6 +6170,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
return from_binary_impl(detail::input_adapter(std::move(first), std::move(last)), input_format_t::bon8, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.13.0, from_bon8(ptr, ptr + len))
|
|
|
|
|
static basic_json from_bon8(const T* ptr, std::size_t len,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_bon8(ptr, ptr + len, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief create a JSON value from an input in BSON format
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/from_bson/
|
|
|
|
|
template<typename InputType>
|
|
|
|
@@ -6010,18 +6215,26 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
static basic_json from_bson(const T* ptr, std::size_t len,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_bson(ptr, ptr + len, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
|
|
|
|
|
static basic_json from_bson(detail::span_input_adapter&& i,
|
|
|
|
|
const bool strict = true,
|
|
|
|
|
const bool allow_exceptions = true)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return from_binary_impl(i.get(), input_format_t::bson, strict, allow_exceptions);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
@@ -6041,9 +6254,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ptr.get_unchecked(this);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief access specified element via JSON Pointer
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
|
|
|
@@ -6055,9 +6272,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ptr.get_unchecked(this);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief access specified element via JSON Pointer
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
|
|
|
@@ -6069,9 +6290,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ptr.get_checked(this);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief access specified element via JSON Pointer
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/at/
|
|
|
|
@@ -6083,9 +6308,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|
|
|
|
template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
|
|
|
|
|
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer<basic_json::string_t>) // NOLINT(readability/alt_tokens)
|
|
|
|
|
const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr) const
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS
|
|
|
|
|
= delete;
|
|
|
|
|
#else
|
|
|
|
|
{
|
|
|
|
|
return ptr.get_checked(this);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/// @brief return flattened JSON value
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/basic_json/flatten/
|
|
|
|
@@ -7062,6 +7291,18 @@ std::string format_as(const NLOHMANN_BASIC_JSON_TPL& j)
|
|
|
|
|
return j.dump();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if JSON_DELETE_DEPRECATED_FUNCTIONS && !defined(JSON_NO_IO)
|
|
|
|
|
/// @brief serialize to stream (deleted; use operator<<(std::ostream&, const basic_json&))
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/operator_ltlt/
|
|
|
|
|
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
|
|
|
|
std::ostream& operator>>(const NLOHMANN_BASIC_JSON_TPL& j, std::ostream& o) = delete;
|
|
|
|
|
|
|
|
|
|
/// @brief deserialize from stream (deleted; use operator>>(std::istream&, basic_json&))
|
|
|
|
|
/// @sa https://json.nlohmann.me/api/operator_gtgt/
|
|
|
|
|
NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
|
|
|
|
std::istream& operator<<(NLOHMANN_BASIC_JSON_TPL& j, std::istream& i) = delete;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
NLOHMANN_JSON_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|