18#ifndef INCLUDE_WPI_JSON_HPP_
19#define INCLUDE_WPI_JSON_HPP_
24#include <initializer_list>
64#if defined(JSON_HAS_CPP_17)
65 #if JSON_HAS_STATIC_RTTI
68 #include <string_view>
98 :
public ::wpi::detail::json_base_class<CustomBaseClass>
104 friend class ::wpi::json_pointer;
108 template<
typename BasicJsonType,
typename InputType>
109 friend class ::wpi::detail::parser;
110 friend ::wpi::detail::serializer<basic_json>;
111 template<
typename BasicJsonType>
112 friend class ::wpi::detail::iter_impl;
113 template<
typename BasicJsonType,
typename CharType>
114 friend class ::wpi::detail::binary_writer;
115 template<
typename BasicJsonType,
typename InputType,
typename SAX>
116 friend class ::wpi::detail::binary_reader;
117 template<
typename BasicJsonType>
118 friend class ::wpi::detail::json_sax_dom_parser;
119 template<
typename BasicJsonType>
120 friend class ::wpi::detail::json_sax_dom_callback_parser;
121 friend class ::wpi::detail::exception;
125 using json_base_class_t = ::wpi::detail::json_base_class<CustomBaseClass>;
129 using lexer = ::wpi::detail::lexer_base<basic_json>;
131 template<
typename InputAdapterType>
132 static ::wpi::detail::parser<basic_json, InputAdapterType>
parser(
133 InputAdapterType adapter,
135 const bool allow_exceptions =
true,
136 const bool ignore_comments =
false
139 return ::wpi::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
140 std::move(cb), allow_exceptions, ignore_comments);
144 using primitive_iterator_t = ::wpi::detail::primitive_iterator_t;
145 template<
typename BasicJsonType>
146 using internal_iterator = ::wpi::detail::internal_iterator<BasicJsonType>;
147 template<
typename BasicJsonType>
148 using iter_impl = ::wpi::detail::iter_impl<BasicJsonType>;
149 template<
typename Iterator>
150 using iteration_proxy = ::wpi::detail::iteration_proxy<Iterator>;
151 template<
typename Base>
using json_reverse_iterator = ::wpi::detail::json_reverse_iterator<Base>;
153 template<
typename CharType>
154 using output_adapter_t = ::wpi::detail::output_adapter_t<CharType>;
156 template<
typename InputType>
157 using binary_reader = ::wpi::detail::binary_reader<basic_json, InputType>;
158 template<
typename CharType>
using binary_writer = ::wpi::detail::binary_writer<basic_json, CharType>;
166 template<
typename T,
typename SFINAE>
222 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
224 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
251 result[
"copyright"] =
"(C) 2013-2023 Niels Lohmann";
252 result[
"name"] =
"JSON for Modern C++";
253 result[
"url"] =
"https://github.com/nlohmann/json";
254 result[
"version"][
"string"] =
263 result[
"platform"] =
"win32";
264#elif defined __linux__
265 result[
"platform"] =
"linux";
266#elif defined __APPLE__
267 result[
"platform"] =
"apple";
268#elif defined __unix__
269 result[
"platform"] =
"unix";
271 result[
"platform"] =
"unknown";
274#if defined(__ICC) || defined(__INTEL_COMPILER)
275 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
276#elif defined(__clang__)
277 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
278#elif defined(__GNUC__) || defined(__GNUG__)
279 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
280 std::to_string(__GNUC__),
'.',
281 std::to_string(__GNUC_MINOR__),
'.',
282 std::to_string(__GNUC_PATCHLEVEL__))
285#elif defined(__HP_cc) || defined(__HP_aCC)
286 result[
"compiler"] =
"hp"
287#elif defined(__IBMCPP__)
288 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
289#elif defined(_MSC_VER)
290 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
292 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
293#elif defined(__SUNPRO_CC)
294 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
296 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
299#if defined(_MSVC_LANG)
300 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
301#elif defined(__cplusplus)
302 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
304 result[
"compiler"][
"c++"] =
"unknown";
322#if defined(JSON_HAS_CPP_14)
335 AllocatorType<std::pair<
const StringType,
340 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
364 using binary_t = wpi::byte_container_with_subtype<BinaryType>;
375 template<
typename T,
typename... Args>
377 static T* create(Args&& ... args)
379 AllocatorType<T> alloc;
380 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
382 auto deleter = [&](T * obj)
384 AllocatorTraits::deallocate(alloc, obj, 1);
386 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
387 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
389 return obj.release();
442 json_value() =
default;
444 json_value(
boolean_t v) noexcept : boolean(v) {}
456 case value_t::object:
458 object = create<object_t>();
464 array = create<array_t>();
468 case value_t::string:
470 string = create<string_t>(
"");
474 case value_t::binary:
476 binary = create<binary_t>();
480 case value_t::boolean:
486 case value_t::number_integer:
492 case value_t::number_unsigned:
498 case value_t::number_float:
510 case value_t::discarded:
556 (t == value_t::object &&
object ==
nullptr) ||
557 (t == value_t::array && array ==
nullptr) ||
558 (t == value_t::string &&
string ==
nullptr) ||
559 (t == value_t::binary && binary ==
nullptr)
565 if (t == value_t::array || t == value_t::object)
568 std::vector<basic_json> stack;
571 if (t == value_t::array)
573 stack.reserve(
array->size());
574 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
579 for (
auto&& it : *
object)
581 stack.push_back(std::move(it.second));
585 while (!stack.empty())
588 basic_json current_item(std::move(stack.back()));
593 if (current_item.is_array())
595 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
597 current_item.m_data.m_value.array->clear();
599 else if (current_item.is_object())
601 for (
auto&& it : *current_item.m_data.m_value.object)
603 stack.push_back(std::move(it.second));
606 current_item.m_data.m_value.object->clear();
616 case value_t::object:
618 AllocatorType<object_t> alloc;
619 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
620 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
626 AllocatorType<array_t> alloc;
627 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
628 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
632 case value_t::string:
634 AllocatorType<string_t> alloc;
635 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
636 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
640 case value_t::binary:
642 AllocatorType<binary_t> alloc;
643 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
644 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
649 case value_t::boolean:
650 case value_t::number_integer:
651 case value_t::number_unsigned:
652 case value_t::number_float:
653 case value_t::discarded:
681 void assert_invariant(
bool check_parents =
true) const noexcept
694 return j.m_parent ==
this;
699 static_cast<void>(check_parents);
709 for (
auto& element : *
m_data.m_value.array)
711 element.m_parent =
this;
716 case value_t::object:
718 for (
auto& element : *
m_data.m_value.object)
720 element.second.m_parent =
this;
726 case value_t::string:
727 case value_t::boolean:
728 case value_t::number_integer:
729 case value_t::number_unsigned:
730 case value_t::number_float:
731 case value_t::binary:
732 case value_t::discarded:
739 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
742 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
744 (it + i)->m_parent =
this;
747 static_cast<void>(count_set_parents);
752 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
755 if (old_capacity !=
static_cast<std::size_t
>(-1))
769#ifdef JSON_HEDLEY_MSVC_VERSION
770#pragma warning(push )
771#pragma warning(disable : 4127)
778#ifdef JSON_HEDLEY_MSVC_VERSION
779#pragma warning( pop )
784 static_cast<void>(j);
785 static_cast<void>(old_capacity);
830 template <
typename CompatibleType,
835 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
836 std::forward<CompatibleType>(val))))
838 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
845 template <
typename BasicJsonType,
850 using other_boolean_t =
typename BasicJsonType::boolean_t;
851 using other_number_float_t =
typename BasicJsonType::number_float_t;
852 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
853 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
854 using other_string_t =
typename BasicJsonType::string_t;
855 using other_object_t =
typename BasicJsonType::object_t;
856 using other_array_t =
typename BasicJsonType::array_t;
857 using other_binary_t =
typename BasicJsonType::binary_t;
861 case value_t::boolean:
862 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
864 case value_t::number_float:
865 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
867 case value_t::number_integer:
868 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
870 case value_t::number_unsigned:
871 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
873 case value_t::string:
876 case value_t::object:
882 case value_t::binary:
888 case value_t::discarded:
889 m_data.m_type = value_t::discarded;
902 bool type_deduction =
true,
903 value_t manual_type = value_t::array)
907 bool is_an_object = std::all_of(init.begin(), init.end(),
913 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
920 if (manual_type == value_t::array)
922 is_an_object =
false;
935 m_data.m_type = value_t::object;
936 m_data.m_value = value_t::object;
938 for (
auto& element_ref : init)
942 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
943 std::move((*element.m_data.m_value.array)[1]));
949 m_data.m_type = value_t::array;
950 m_data.m_value.array = create<array_t>(init.begin(), init.end());
963 res.m_data.m_type = value_t::binary;
964 res.m_data.m_value = init;
971 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
974 res.m_data.m_type = value_t::binary;
975 res.m_data.m_value =
binary_t(init, subtype);
985 res.m_data.m_type = value_t::binary;
986 res.m_data.m_value = std::move(init);
993 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
996 res.m_data.m_type = value_t::binary;
997 res.m_data.m_value =
binary_t(std::move(init), subtype);
1006 return basic_json(init,
false, value_t::array);
1014 return basic_json(init,
false, value_t::object);
1028 template <
class InputIT,
typename std::enable_if <
1029 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
1030 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
1043 m_data.m_type = first.m_object->m_data.m_type;
1048 case value_t::boolean:
1049 case value_t::number_float:
1050 case value_t::number_integer:
1051 case value_t::number_unsigned:
1052 case value_t::string:
1055 || !last.m_it.primitive_iterator.is_end()))
1063 case value_t::object:
1064 case value_t::array:
1065 case value_t::binary:
1066 case value_t::discarded:
1073 case value_t::number_integer:
1075 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
1079 case value_t::number_unsigned:
1081 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
1085 case value_t::number_float:
1087 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
1091 case value_t::boolean:
1093 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
1097 case value_t::string:
1099 m_data.m_value = *first.m_object->m_data.m_value.string;
1103 case value_t::object:
1105 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
1106 last.m_it.object_iterator);
1110 case value_t::array:
1112 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
1113 last.m_it.array_iterator);
1117 case value_t::binary:
1119 m_data.m_value = *first.m_object->m_data.m_value.binary;
1124 case value_t::discarded:
1137 template<
typename JsonRef,
1139 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
1145 : json_base_class_t(other)
1147 m_data.m_type = other.m_data.m_type;
1149 other.assert_invariant();
1153 case value_t::object:
1155 m_data.m_value = *other.m_data.m_value.object;
1159 case value_t::array:
1161 m_data.m_value = *other.m_data.m_value.array;
1165 case value_t::string:
1167 m_data.m_value = *other.m_data.m_value.string;
1171 case value_t::boolean:
1173 m_data.m_value = other.m_data.m_value.boolean;
1177 case value_t::number_integer:
1179 m_data.m_value = other.m_data.m_value.number_integer;
1183 case value_t::number_unsigned:
1185 m_data.m_value = other.m_data.m_value.number_unsigned;
1189 case value_t::number_float:
1191 m_data.m_value = other.m_data.m_value.number_float;
1195 case value_t::binary:
1197 m_data.m_value = *other.m_data.m_value.binary;
1202 case value_t::discarded:
1214 : json_base_class_t(std::forward<json_base_class_t>(other)),
1215 m_data(std::move(other.m_data))
1218 other.assert_invariant(
false);
1221 other.m_data.m_type = value_t::null;
1222 other.m_data.m_value = {};
1231 std::is_nothrow_move_constructible<value_t>::value&&
1232 std::is_nothrow_move_assignable<value_t>::value&&
1233 std::is_nothrow_move_constructible<json_value>::value&&
1234 std::is_nothrow_move_assignable<json_value>::value&&
1235 std::is_nothrow_move_assignable<json_base_class_t>::value
1239 other.assert_invariant();
1242 swap(m_data.m_type, other.m_data.m_type);
1243 swap(m_data.m_value, other.m_data.m_value);
1244 json_base_class_t::operator=(std::move(other));
1255 assert_invariant(
false);
1272 const char indent_char =
' ',
1273 const bool ensure_ascii =
false,
1281 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
1285 s.dump(*
this,
false, ensure_ascii, 0);
1291 void dump(raw_ostream& os,
const int indent = -1,
1292 const char indent_char =
' ',
1293 const bool ensure_ascii =
false,
1294 const error_handler_t error_handler = error_handler_t::strict)
const {
1299 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
1303 s.dump(*
this,
false, ensure_ascii, 0);
1313 return m_data.m_type;
1320 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
1327 return is_array() || is_object();
1334 return m_data.m_type == value_t::null;
1341 return m_data.m_type == value_t::boolean;
1348 return is_number_integer() || is_number_float();
1355 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
1362 return m_data.m_type == value_t::number_unsigned;
1369 return m_data.m_type == value_t::number_float;
1376 return m_data.m_type == value_t::object;
1383 return m_data.m_type == value_t::array;
1390 return m_data.m_type == value_t::string;
1397 return m_data.m_type == value_t::binary;
1404 return m_data.m_type == value_t::discarded;
1411 return m_data.m_type;
1422 boolean_t get_impl(boolean_t* )
const
1426 return m_data.m_value.boolean;
1433 object_t* get_impl_ptr(object_t* )
noexcept
1435 return is_object() ? m_data.m_value.object :
nullptr;
1439 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
1441 return is_object() ? m_data.m_value.object :
nullptr;
1445 array_t* get_impl_ptr(array_t* )
noexcept
1447 return is_array() ? m_data.m_value.array :
nullptr;
1451 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
1453 return is_array() ? m_data.m_value.array :
nullptr;
1457 string_t* get_impl_ptr(string_t* )
noexcept
1459 return is_string() ? m_data.m_value.string :
nullptr;
1463 constexpr const string_t* get_impl_ptr(
const string_t* )
const noexcept
1465 return is_string() ? m_data.m_value.string :
nullptr;
1469 boolean_t* get_impl_ptr(boolean_t* )
noexcept
1471 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
1475 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
1477 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
1481 number_integer_t* get_impl_ptr(number_integer_t* )
noexcept
1483 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
1487 constexpr const number_integer_t* get_impl_ptr(
const number_integer_t* )
const noexcept
1489 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
1493 number_unsigned_t* get_impl_ptr(number_unsigned_t* )
noexcept
1495 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
1499 constexpr const number_unsigned_t* get_impl_ptr(
const number_unsigned_t* )
const noexcept
1501 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
1505 number_float_t* get_impl_ptr(number_float_t* )
noexcept
1507 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
1511 constexpr const number_float_t* get_impl_ptr(
const number_float_t* )
const noexcept
1513 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
1517 binary_t* get_impl_ptr(binary_t* )
noexcept
1519 return is_binary() ? m_data.m_value.binary :
nullptr;
1523 constexpr const binary_t* get_impl_ptr(
const binary_t* )
const noexcept
1525 return is_binary() ? m_data.m_value.binary :
nullptr;
1539 template<
typename ReferenceType,
typename ThisType>
1540 static ReferenceType get_ref_impl(ThisType& obj)
1543 auto*
ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
1550 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
1560 template<
typename PointerType,
typename std::enable_if<
1561 std::is_pointer<PointerType>::value,
int>::type = 0>
1562 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
1565 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
1570 template <
typename PointerType,
typename std::enable_if <
1571 std::is_pointer<PointerType>::value&&
1572 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
1573 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
1576 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
1618 template <
typename ValueType,
1624 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
1626 auto ret = ValueType();
1627 JSONSerializer<ValueType>::from_json(*
this, ret);
1661 template <
typename ValueType,
1666 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
1668 return JSONSerializer<ValueType>::from_json(*
this);
1686 template <
typename BasicJsonType,
1709 template<
typename BasicJsonType,
1711 std::is_same<BasicJsonType, basic_json_t>::value,
1722 template<
typename PointerType,
1724 std::is_pointer<PointerType>::value,
1727 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
1730 return get_ptr<PointerType>();
1757 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
1758#if defined(JSON_HAS_CPP_14)
1762 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
1768 static_assert(!std::is_reference<ValueTypeCV>::value,
1769 "get() cannot be used with reference types, you might want to use get_ref()");
1800 template<
typename PointerType,
typename std::enable_if<
1801 std::is_pointer<PointerType>::value,
int>::type = 0>
1802 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template get_ptr<PointerType>())
1805 return get_ptr<PointerType>();
1810 template <
typename ValueType,
1815 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
1816 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
1818 JSONSerializer<ValueType>::from_json(*
this, v);
1824 template<
typename ValueType,
1835 typename T, std::size_t N,
1836 typename Array = T (&)[N],
1840 noexcept(
noexcept(JSONSerializer<Array>::from_json(
1841 std::declval<const basic_json_t&>(), v)))
1843 JSONSerializer<Array>::from_json(*
this, v);
1849 template<
typename ReferenceType,
typename std::enable_if<
1850 std::is_reference<ReferenceType>::value,
int>::type = 0>
1854 return get_ref_impl<ReferenceType>(*
this);
1859 template <
typename ReferenceType,
typename std::enable_if <
1860 std::is_reference<ReferenceType>::value&&
1861 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
1865 return get_ref_impl<ReferenceType>(*
this);
1897 template <
typename ValueType,
typename std::enable_if <
1905#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
1908#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
1912 >::value,
int >::type = 0 >
1928 return *get_ptr<binary_t*>();
1940 return *get_ptr<const binary_t*>();
1962 return set_parent(m_data.m_value.array->at(idx));
1967 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
1985 return m_data.m_value.array->at(idx);
1990 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
2009 auto it = m_data.
m_value.object->find(key);
2010 if (it == m_data.m_value.object->end())
2014 return set_parent(it->second);
2029 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
2030 if (it == m_data.m_value.object->end())
2034 return set_parent(it->second);
2047 auto it = m_data.
m_value.object->find(key);
2048 if (it == m_data.m_value.object->end())
2067 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
2068 if (it == m_data.m_value.object->end())
2082 m_data.m_type = value_t::array;
2083 m_data.m_value.array = create<array_t>();
2091 if (idx >= m_data.m_value.array->size())
2095 const auto old_size = m_data.m_value.array->size();
2096 const auto old_capacity = m_data.m_value.array->capacity();
2098 m_data.m_value.array->resize(idx + 1);
2109 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
2115 return m_data.m_value.array->operator[](idx);
2118 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
2128 return m_data.m_value.array->operator[](idx);
2131 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
2141 m_data.m_type = value_t::object;
2142 m_data.m_value.object = create<object_t>();
2149 auto result = m_data.m_value.object->emplace(std::move(key),
nullptr);
2150 return set_parent(result.first->second);
2153 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
2163 auto it = m_data.m_value.object->find(key);
2168 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
2173 template<
typename T>
2176 return operator[](
typename object_t::key_type(key));
2179 template<
typename T>
2182 return operator[](
typename object_t::key_type(key));
2194 m_data.m_type = value_t::object;
2195 m_data.m_value.object = create<object_t>();
2202 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
2203 return set_parent(result.first->second);
2206 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
2218 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
2223 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
2227 template<
typename KeyType>
2229 object_comparator_t,
const typename object_t::key_type&, KeyType >;
2231 template<
typename ValueType>
2232 using value_return_type = std::conditional <
2234 string_t,
typename std::decay<ValueType>::type >;
2242 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2243 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
2249 const auto it = find(key);
2255 return default_value;
2263 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
2267 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2268 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
2274 const auto it = find(key);
2280 return std::forward<ValueType>(default_value);
2291 && is_comparable_with_object_key<KeyType>::value
2293 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2294 ValueType
value(KeyType && key,
const ValueType& default_value)
const
2300 const auto it = find(std::forward<KeyType>(key));
2306 return default_value;
2314 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
2318 && is_comparable_with_object_key<KeyType>::value
2320 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2321 ReturnType
value(KeyType && key, ValueType && default_value)
const
2327 const auto it = find(std::forward<KeyType>(key));
2333 return std::forward<ValueType>(default_value);
2343 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2356 return default_value;
2365 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
2368 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2381 return std::forward<ValueType>(default_value);
2391 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2395 return value(
ptr.convert(), default_value);
2398 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
2402 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
2406 return value(
ptr.convert(), std::forward<ValueType>(default_value));
2444 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
2445 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
2451 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
2454 IteratorType result = end();
2456 switch (m_data.m_type)
2458 case value_t::boolean:
2459 case value_t::number_float:
2460 case value_t::number_integer:
2461 case value_t::number_unsigned:
2462 case value_t::string:
2463 case value_t::binary:
2467 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
2472 AllocatorType<string_t> alloc;
2473 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
2474 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
2475 m_data.m_value.string =
nullptr;
2477 else if (is_binary())
2479 AllocatorType<binary_t> alloc;
2480 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
2481 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
2482 m_data.m_value.binary =
nullptr;
2485 m_data.m_type = value_t::null;
2490 case value_t::object:
2492 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
2496 case value_t::array:
2498 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
2503 case value_t::discarded:
2514 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
2515 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
2516 IteratorType
erase(IteratorType first, IteratorType last)
2521 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
2524 IteratorType result = end();
2526 switch (m_data.m_type)
2528 case value_t::boolean:
2529 case value_t::number_float:
2530 case value_t::number_integer:
2531 case value_t::number_unsigned:
2532 case value_t::string:
2533 case value_t::binary:
2536 || !last.m_it.primitive_iterator.is_end()))
2538 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
2543 AllocatorType<string_t> alloc;
2544 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
2545 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
2546 m_data.m_value.string =
nullptr;
2548 else if (is_binary())
2550 AllocatorType<binary_t> alloc;
2551 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
2552 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
2553 m_data.m_value.binary =
nullptr;
2556 m_data.m_type = value_t::null;
2561 case value_t::object:
2563 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
2564 last.m_it.object_iterator);
2568 case value_t::array:
2570 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
2571 last.m_it.array_iterator);
2576 case value_t::discarded:
2587 size_type erase_internal(KeyType && key)
2595 return m_data.m_value.object->erase(std::forward<KeyType>(key));
2600 size_type erase_internal(KeyType && key)
2608 const auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
2609 if (it != m_data.m_value.object->end())
2611 m_data.m_value.object->erase(it);
2625 return erase_internal(key);
2634 return erase_internal(std::forward<KeyType>(key));
2646 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
2649 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
2670 auto result = end();
2674 result.m_it.object_iterator = m_data.m_value.object->find(key);
2684 auto result = cend();
2688 result.m_it.object_iterator = m_data.m_value.object->find(key);
2700 auto result = end();
2704 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
2716 auto result = cend();
2720 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
2731 return is_object() ? m_data.m_value.object->count(key) : 0;
2741 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
2746 bool contains(
const typename object_t::key_type& key)
const
2748 return is_object() && m_data.m_value.object->find(key) != m_data.m_value.object->end();
2757 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(key)) != m_data.m_value.object->end();
2764 return ptr.contains(
this);
2767 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
2771 return ptr.contains(
this);
2900 iteration_proxy<iterator>
items() noexcept
2902 return iteration_proxy<iterator>(*
this);
2907 iteration_proxy<const_iterator>
items() const noexcept
2909 return iteration_proxy<const_iterator>(*
this);
2925 switch (m_data.m_type)
2933 case value_t::array:
2936 return m_data.m_value.array->empty();
2939 case value_t::object:
2942 return m_data.m_value.object->empty();
2945 case value_t::string:
2946 case value_t::boolean:
2947 case value_t::number_integer:
2948 case value_t::number_unsigned:
2949 case value_t::number_float:
2950 case value_t::binary:
2951 case value_t::discarded:
2964 switch (m_data.m_type)
2972 case value_t::array:
2975 return m_data.m_value.array->size();
2978 case value_t::object:
2981 return m_data.m_value.object->size();
2984 case value_t::string:
2985 case value_t::boolean:
2986 case value_t::number_integer:
2987 case value_t::number_unsigned:
2988 case value_t::number_float:
2989 case value_t::binary:
2990 case value_t::discarded:
3003 switch (m_data.m_type)
3005 case value_t::array:
3008 return m_data.m_value.array->max_size();
3011 case value_t::object:
3014 return m_data.m_value.object->max_size();
3018 case value_t::string:
3019 case value_t::boolean:
3020 case value_t::number_integer:
3021 case value_t::number_unsigned:
3022 case value_t::number_float:
3023 case value_t::binary:
3024 case value_t::discarded:
3046 switch (m_data.m_type)
3048 case value_t::number_integer:
3050 m_data.m_value.number_integer = 0;
3054 case value_t::number_unsigned:
3056 m_data.m_value.number_unsigned = 0;
3060 case value_t::number_float:
3062 m_data.m_value.number_float = 0.0;
3066 case value_t::boolean:
3068 m_data.m_value.boolean =
false;
3072 case value_t::string:
3074 m_data.m_value.string->clear();
3078 case value_t::binary:
3080 m_data.m_value.binary->clear();
3084 case value_t::array:
3086 m_data.m_value.array->clear();
3090 case value_t::object:
3092 m_data.m_value.object->clear();
3097 case value_t::discarded:
3116 m_data.m_type = value_t::array;
3117 m_data.m_value = value_t::array;
3122 const auto old_capacity = m_data.m_value.array->capacity();
3123 m_data.m_value.array->push_back(std::move(val));
3124 set_parent(m_data.m_value.array->back(), old_capacity);
3132 push_back(std::move(val));
3149 m_data.m_type = value_t::array;
3150 m_data.m_value = value_t::array;
3155 const auto old_capacity = m_data.m_value.array->capacity();
3156 m_data.m_value.array->push_back(val);
3157 set_parent(m_data.m_value.array->back(), old_capacity);
3181 m_data.m_type = value_t::object;
3182 m_data.m_value = value_t::object;
3187 auto res = m_data.m_value.object->insert(val);
3188 set_parent(res.first->second);
3203 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
3205 basic_json&& key = init.begin()->moved_or_copied();
3206 push_back(
typename object_t::value_type(
3207 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
3225 template<
class... Args>
3237 m_data.m_type = value_t::array;
3238 m_data.m_value = value_t::array;
3243 const auto old_capacity = m_data.
m_value.array->capacity();
3244 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
3245 return set_parent(m_data.m_value.array->back(), old_capacity);
3250 template<
class... Args>
3251 std::pair<iterator, bool>
emplace(Args&& ... args)
3262 m_data.m_type = value_t::object;
3263 m_data.m_value = value_t::object;
3268 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
3269 set_parent(res.first->second);
3273 it.m_it.object_iterator = res.first;
3276 return {it, res.second};
3282 template<
typename... Args>
3288 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
3289 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
3290 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
3310 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
3314 return insert_iterator(pos, val);
3324 return insert(pos, val);
3337 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
3341 return insert_iterator(pos, cnt, val);
3360 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
3366 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
3371 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
3375 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
3391 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
3395 return insert_iterator(pos, ilist.begin(), ilist.end());
3411 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
3417 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
3420 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
3427 update(j.
begin(), j.
end(), merge_objects);
3437 m_data.m_type = value_t::object;
3438 m_data.m_value.object = create<object_t>();
3450 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
3456 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
3459 for (
auto it = first; it != last; ++it)
3461 if (merge_objects && it.value().is_object())
3463 auto it2 = m_data.m_value.object->find(it.key());
3464 if (it2 != m_data.m_value.object->end())
3466 it2->second.update(it.value(),
true);
3470 m_data.m_value.object->operator[](it.key()) = it.value();
3472 m_data.m_value.object->operator[](it.key()).m_parent =
this;
3480 std::is_nothrow_move_constructible<value_t>::value&&
3481 std::is_nothrow_move_assignable<value_t>::value&&
3482 std::is_nothrow_move_constructible<json_value>::value&&
3483 std::is_nothrow_move_assignable<json_value>::value
3486 std::swap(m_data.m_type, other.m_data.m_type);
3487 std::swap(m_data.m_value, other.m_data.m_value);
3490 other.set_parents();
3497 std::is_nothrow_move_constructible<value_t>::value&&
3498 std::is_nothrow_move_assignable<value_t>::value&&
3499 std::is_nothrow_move_constructible<json_value>::value&&
3500 std::is_nothrow_move_assignable<json_value>::value
3514 swap(*(m_data.m_value.array), other);
3530 swap(*(m_data.m_value.object), other);
3546 swap(*(m_data.m_value.string), other);
3562 swap(*(m_data.m_value.binary), other);
3572 void swap(
typename binary_t::container_type& other)
3578 swap(*(m_data.m_value.binary), other);
3582 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
3597#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
3598 const auto lhs_type = lhs.type(); \
3599 const auto rhs_type = rhs.type(); \
3601 if (lhs_type == rhs_type) \
3605 case value_t::array: \
3606 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
3608 case value_t::object: \
3609 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
3611 case value_t::null: \
3612 return (null_result); \
3614 case value_t::string: \
3615 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
3617 case value_t::boolean: \
3618 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
3620 case value_t::number_integer: \
3621 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
3623 case value_t::number_unsigned: \
3624 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
3626 case value_t::number_float: \
3627 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
3629 case value_t::binary: \
3630 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
3632 case value_t::discarded: \
3634 return (unordered_result); \
3637 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
3639 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
3641 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
3643 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
3645 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
3647 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
3649 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
3651 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
3653 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
3655 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
3657 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
3659 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
3661 else if(compares_unordered(lhs, rhs))\
3663 return (unordered_result);\
3666 return (default_result);
3681#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
3684 static_cast<void>(inverse);
3690 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
3692 return compares_unordered(*
this, rhs, inverse);
3696#if JSON_HAS_THREE_WAY_COMPARISON
3699 bool operator==(const_reference rhs)
const noexcept
3702#pragma GCC diagnostic push
3703#pragma GCC diagnostic ignored "-Wfloat-equal"
3705 const_reference lhs = *
this;
3708#pragma GCC diagnostic pop
3714 template<
typename ScalarType>
3715 requires std::is_scalar_v<ScalarType>
3716 bool operator==(ScalarType rhs)
const noexcept
3723 bool operator!=(const_reference rhs)
const noexcept
3725 if (compares_unordered(rhs,
true))
3734 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
3736 const_reference lhs = *
this;
3740 std::partial_ordering::equivalent,
3741 std::partial_ordering::unordered,
3742 lhs_type <=> rhs_type)
3747 template<
typename ScalarType>
3748 requires std::is_scalar_v<ScalarType>
3749 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
3754#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
3761 bool operator<=(const_reference rhs)
const noexcept
3763 if (compares_unordered(rhs,
true))
3767 return !(rhs < *
this);
3772 template<
typename ScalarType>
3773 requires std::is_scalar_v<ScalarType>
3774 bool operator<=(ScalarType rhs)
const noexcept
3782 bool operator>=(const_reference rhs)
const noexcept
3784 if (compares_unordered(rhs,
true))
3788 return !(*
this < rhs);
3793 template<
typename ScalarType>
3794 requires std::is_scalar_v<ScalarType>
3795 bool operator>=(ScalarType rhs)
const noexcept
3803 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
3806#pragma GCC diagnostic push
3807#pragma GCC diagnostic ignored "-Wfloat-equal"
3811#pragma GCC diagnostic pop
3817 template<
typename ScalarType,
typename std::enable_if<
3818 std::is_scalar<ScalarType>::value,
int>::type = 0>
3819 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
3826 template<
typename ScalarType,
typename std::enable_if<
3827 std::is_scalar<ScalarType>::value,
int>::type = 0>
3828 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
3835 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
3837 if (compares_unordered(lhs, rhs,
true))
3841 return !(lhs == rhs);
3846 template<
typename ScalarType,
typename std::enable_if<
3847 std::is_scalar<ScalarType>::value,
int>::type = 0>
3848 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
3855 template<
typename ScalarType,
typename std::enable_if<
3856 std::is_scalar<ScalarType>::value,
int>::type = 0>
3857 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
3864 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
3874 template<
typename ScalarType,
typename std::enable_if<
3875 std::is_scalar<ScalarType>::value,
int>::type = 0>
3876 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
3883 template<
typename ScalarType,
typename std::enable_if<
3884 std::is_scalar<ScalarType>::value,
int>::type = 0>
3885 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
3892 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
3894 if (compares_unordered(lhs, rhs,
true))
3898 return !(rhs < lhs);
3903 template<
typename ScalarType,
typename std::enable_if<
3904 std::is_scalar<ScalarType>::value,
int>::type = 0>
3905 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
3912 template<
typename ScalarType,
typename std::enable_if<
3913 std::is_scalar<ScalarType>::value,
int>::type = 0>
3914 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
3921 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
3924 if (compares_unordered(lhs, rhs))
3928 return !(lhs <= rhs);
3933 template<
typename ScalarType,
typename std::enable_if<
3934 std::is_scalar<ScalarType>::value,
int>::type = 0>
3935 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
3942 template<
typename ScalarType,
typename std::enable_if<
3943 std::is_scalar<ScalarType>::value,
int>::type = 0>
3944 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
3951 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
3953 if (compares_unordered(lhs, rhs,
true))
3957 return !(lhs < rhs);
3962 template<
typename ScalarType,
typename std::enable_if<
3963 std::is_scalar<ScalarType>::value,
int>::type = 0>
3964 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
3971 template<
typename ScalarType,
typename std::enable_if<
3972 std::is_scalar<ScalarType>::value,
int>::type = 0>
3973 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
3979#undef JSON_IMPLEMENT_OPERATOR
3995 const bool pretty_print = o.width() > 0;
3996 const auto indentation = pretty_print ? o.width() : 0;
4003 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
4014 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
4036 template<
typename InputType>
4039 const parser_callback_t cb =
nullptr,
4040 const bool allow_exceptions =
true,
4041 const bool ignore_comments =
false)
4044 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
4050 template<
typename IteratorType>
4054 const parser_callback_t cb =
nullptr,
4055 const bool allow_exceptions =
true,
4056 const bool ignore_comments =
false)
4059 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
4066 const parser_callback_t cb =
nullptr,
4067 const bool allow_exceptions =
true,
4068 const bool ignore_comments =
false)
4071 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
4077 template<
typename InputType>
4078 static bool accept(InputType&& i,
4079 const bool ignore_comments =
false)
4081 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
4086 template<
typename IteratorType>
4087 static bool accept(IteratorType first, IteratorType last,
4088 const bool ignore_comments =
false)
4090 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
4096 const bool ignore_comments =
false)
4098 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
4103 template <
typename InputType,
typename SAX>
4105 static
bool sax_parse(InputType&& i, SAX* sax,
4107 const
bool strict = true,
4108 const
bool ignore_comments = false)
4111 return format == input_format_t::json
4112 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4118 template<
class IteratorType,
class SAX>
4120 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
4122 const
bool strict = true,
4123 const
bool ignore_comments = false)
4126 return format == input_format_t::json
4127 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4136 template <
typename SAX>
4139 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
4141 const
bool strict = true,
4142 const
bool ignore_comments = false)
4145 return format == input_format_t::json
4147 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4161 return operator>>(i, j);
4183 switch (m_data.m_type)
4187 case value_t::object:
4189 case value_t::array:
4191 case value_t::string:
4193 case value_t::boolean:
4195 case value_t::binary:
4197 case value_t::discarded:
4199 case value_t::number_integer:
4200 case value_t::number_unsigned:
4201 case value_t::number_float:
4215 value_t m_type = value_t::null;
4218 json_value m_value = {};
4221 : m_type(v), m_value(v)
4228 m_value.array = create<array_t>(cnt, val);
4232 data(data&&) noexcept = default;
4233 data(const data&) noexcept = delete;
4234 data& operator=(data&&) noexcept = delete;
4235 data& operator=(const data&) noexcept = delete;
4239 m_value.destroy(m_type);
4262 std::vector<std::uint8_t> result;
4271 binary_writer<std::uint8_t>(o).write_cbor(j);
4278 binary_writer<char>(o).write_cbor(j);
4285 std::vector<std::uint8_t> result;
4286 to_msgpack(j, result);
4294 binary_writer<std::uint8_t>(o).write_msgpack(j);
4301 binary_writer<char>(o).write_msgpack(j);
4307 const bool use_size =
false,
4308 const bool use_type =
false)
4310 std::vector<std::uint8_t> result;
4311 to_ubjson(j, result, use_size, use_type);
4318 const bool use_size =
false,
const bool use_type =
false)
4320 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
4326 const bool use_size =
false,
const bool use_type =
false)
4328 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
4334 const bool use_size =
false,
4335 const bool use_type =
false)
4337 std::vector<std::uint8_t> result;
4338 to_bjdata(j, result, use_size, use_type);
4345 const bool use_size =
false,
const bool use_type =
false)
4347 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
4353 const bool use_size =
false,
const bool use_type =
false)
4355 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
4362 std::vector<std::uint8_t> result;
4371 binary_writer<std::uint8_t>(o).write_bson(j);
4378 binary_writer<char>(o).write_bson(j);
4383 template<
typename InputType>
4386 const bool strict =
true,
4387 const bool allow_exceptions =
true,
4393 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
4394 return res ? result :
basic_json(value_t::discarded);
4399 template<
typename IteratorType>
4402 const bool strict =
true,
4403 const bool allow_exceptions =
true,
4409 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
4410 return res ? result :
basic_json(value_t::discarded);
4413 template<
typename T>
4417 const
bool strict = true,
4418 const
bool allow_exceptions = true,
4421 return from_cbor(
ptr,
ptr + len, strict, allow_exceptions, tag_handler);
4427 const
bool strict = true,
4428 const
bool allow_exceptions = true,
4435 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
4436 return res ? result :
basic_json(value_t::discarded);
4441 template<
typename InputType>
4444 const bool strict =
true,
4445 const bool allow_exceptions =
true)
4450 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
4451 return res ? result :
basic_json(value_t::discarded);
4456 template<
typename IteratorType>
4459 const bool strict =
true,
4460 const bool allow_exceptions =
true)
4465 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
4466 return res ? result :
basic_json(value_t::discarded);
4469 template<
typename T>
4473 const
bool strict = true,
4474 const
bool allow_exceptions = true)
4476 return from_msgpack(
ptr,
ptr + len, strict, allow_exceptions);
4482 const
bool strict = true,
4483 const
bool allow_exceptions = true)
4489 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
4490 return res ? result :
basic_json(value_t::discarded);
4495 template<
typename InputType>
4498 const bool strict =
true,
4499 const bool allow_exceptions =
true)
4504 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
4505 return res ? result :
basic_json(value_t::discarded);
4510 template<
typename IteratorType>
4513 const bool strict =
true,
4514 const bool allow_exceptions =
true)
4519 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
4520 return res ? result :
basic_json(value_t::discarded);
4523 template<
typename T>
4527 const
bool strict = true,
4528 const
bool allow_exceptions = true)
4530 return from_ubjson(
ptr,
ptr + len, strict, allow_exceptions);
4536 const
bool strict = true,
4537 const
bool allow_exceptions = true)
4543 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
4544 return res ? result :
basic_json(value_t::discarded);
4549 template<
typename InputType>
4552 const bool strict =
true,
4553 const bool allow_exceptions =
true)
4558 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
4559 return res ? result :
basic_json(value_t::discarded);
4564 template<
typename IteratorType>
4567 const bool strict =
true,
4568 const bool allow_exceptions =
true)
4573 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
4574 return res ? result :
basic_json(value_t::discarded);
4579 template<
typename InputType>
4582 const bool strict =
true,
4583 const bool allow_exceptions =
true)
4588 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
4589 return res ? result :
basic_json(value_t::discarded);
4594 template<
typename IteratorType>
4597 const bool strict =
true,
4598 const bool allow_exceptions =
true)
4603 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
4604 return res ? result :
basic_json(value_t::discarded);
4607 template<
typename T>
4611 const
bool strict = true,
4612 const
bool allow_exceptions = true)
4614 return from_bson(
ptr,
ptr + len, strict, allow_exceptions);
4620 const
bool strict = true,
4621 const
bool allow_exceptions = true)
4627 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
4628 return res ? result :
basic_json(value_t::discarded);
4643 return ptr.get_unchecked(
this);
4646 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
4650 return ptr.get_unchecked(
this);
4657 return ptr.get_unchecked(
this);
4660 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
4664 return ptr.get_unchecked(
this);
4671 return ptr.get_checked(
this);
4674 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
4678 return ptr.get_checked(
this);
4685 return ptr.get_checked(
this);
4688 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
4692 return ptr.get_checked(
this);
4700 json_pointer::flatten(
"", *
this, result);
4708 return json_pointer::unflatten(*
this);
4726 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
4728 const auto get_op = [](
const std::string & op)
4732 return patch_operations::add;
4736 return patch_operations::remove;
4738 if (op ==
"replace")
4740 return patch_operations::replace;
4744 return patch_operations::move;
4748 return patch_operations::copy;
4752 return patch_operations::test;
4755 return patch_operations::invalid;
4770 if (top_pointer !=
ptr)
4772 result.at(top_pointer);
4776 const auto last_path =
ptr.
back();
4781 switch (parent.
m_data.m_type)
4784 case value_t::object:
4787 parent[last_path] = val;
4791 case value_t::array:
4793 if (last_path ==
"-")
4800 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
4804 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
4814 case value_t::string:
4815 case value_t::boolean:
4816 case value_t::number_integer:
4817 case value_t::number_unsigned:
4818 case value_t::number_float:
4819 case value_t::binary:
4820 case value_t::discarded:
4830 const auto last_path =
ptr.back();
4838 auto it = parent.
find(last_path);
4851 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
4858 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
4862 for (
const auto& val : json_patch)
4865 const auto get_value = [&val](
const std::string & op,
4866 const std::string & member,
4870 auto it = val.m_data.m_value.object->find(member);
4873 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
4886 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
4896 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
4906 case patch_operations::add:
4908 operation_add(
ptr, get_value(
"add",
"value",
false));
4912 case patch_operations::remove:
4914 operation_remove(
ptr);
4918 case patch_operations::replace:
4921 result.at(
ptr) = get_value(
"replace",
"value",
false);
4925 case patch_operations::move:
4927 const auto from_path = get_value(
"move",
"from",
true).template
get<std::string>();
4937 operation_remove(from_ptr);
4938 operation_add(
ptr, v);
4942 case patch_operations::copy:
4944 const auto from_path = get_value(
"copy",
"from",
true).template
get<std::string>();
4953 operation_add(
ptr, v);
4957 case patch_operations::test:
4959 bool success =
false;
4964 success = (result.at(
ptr) == get_value(
"test",
"value",
false));
4980 case patch_operations::invalid:
5004 const std::string& path =
"")
5020 {
"op",
"replace"}, {
"path", path}, {
"value", target}
5027 case value_t::array:
5031 while (i <
source.size() && i < target.
size())
5035 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
5044 while (i <
source.size())
5048 result.insert(result.begin() + end_index,
object(
5051 {
"path", detail::concat(path,
'/', std::to_string(i))}
5057 while (i < target.
size())
5063 {
"value", target[i]}
5071 case value_t::object:
5074 for (
auto it =
source.cbegin(); it !=
source.cend(); ++it)
5079 if (target.
find(it.key()) != target.
end())
5082 auto temp_diff = diff(it.value(), target[it.key()], path_key);
5083 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
5088 result.push_back(
object(
5090 {
"op",
"remove"}, {
"path", path_key}
5096 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
5104 {
"op",
"add"}, {
"path", path_key},
5105 {
"value", it.value()}
5114 case value_t::string:
5115 case value_t::boolean:
5116 case value_t::number_integer:
5117 case value_t::number_unsigned:
5118 case value_t::number_float:
5119 case value_t::binary:
5120 case value_t::discarded:
5126 {
"op",
"replace"}, {
"path", path}, {
"value", target}
5153 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
5155 if (it.value().is_null())
5161 operator[](it.key()).merge_patch(it.value());
5167 *
this = apply_patch;
5184inline namespace json_literals
5190#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5191 inline wpi::json
operator ""_json(
const char* s, std::size_t n)
5193 inline wpi::json
operator "" _json(
const char* s, std::size_t n)
5196 return wpi::json::parse(s, s + n);
5202#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5229 return wpi::detail::hash(j);
5235struct less< ::wpi::detail::value_t>
5242 ::wpi::detail::value_t rhs)
const noexcept
5244#if JSON_HAS_THREE_WAY_COMPARISON
5245 return std::is_lt(lhs <=> rhs);
5247 return ::wpi::detail::operator<(lhs, rhs);
5253#ifndef JSON_HAS_CPP_20
5258inline void swap(wpi::WPI_BASIC_JSON_TPL& j1, wpi::WPI_BASIC_JSON_TPL& j2)
noexcept(
5259 is_nothrow_move_constructible<wpi::WPI_BASIC_JSON_TPL>::value&&
5260 is_nothrow_move_assignable<wpi::WPI_BASIC_JSON_TPL>::value)
5269#if JSON_USE_GLOBAL_UDLS
5270 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
5271 using wpi::literals::json_literals::operator
""_json;
5272 using wpi::literals::json_literals::operator
""_json_pointer;
5274 using wpi::literals::json_literals::operator
"" _json;
5275 using wpi::literals::json_literals::operator
"" _json_pointer;
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or and nanopb were all modified for use in Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation source
Definition ThirdPartyNotices.txt:124
#define WPI_JSON_VERSION_MAJOR
Definition abi_macros.h:21
#define WPI_JSON_VERSION_PATCH
Definition abi_macros.h:23
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition abi_macros.h:30
#define WPI_JSON_VERSION_MINOR
Definition abi_macros.h:22
#define WPI_JSON_NAMESPACE_END
Definition abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition abi_macros.h:53
constexpr T & get(wpi::array< T, N > &arr) noexcept
Definition array.h:66
namespace for Niels Lohmann
Definition json.h:99
constexpr bool is_string() const noexcept
return whether value is a string
Definition json.h:1388
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.h:2621
reference operator[](KeyType &&key)
access specified object element
Definition json.h:2189
size_type size() const noexcept
returns the number of elements
Definition json.h:2962
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.h:4401
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.h:4333
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition json.h:1761
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.h:2819
reference back()
access the last element
Definition json.h:2425
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition json.h:834
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.h:2835
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition json.h:4993
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition json.h:4181
const_reference front() const
access the first element
Definition json.h:2418
constexpr bool is_array() const noexcept
return whether value is an array
Definition json.h:1381
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 &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.h:3479
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.h:2369
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.h:2738
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition json.h:229
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.h:4352
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition json.h:1353
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition json.h:233
data(size_type cnt, const basic_json &val)
Definition json.h:4225
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.h:4596
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.h:4344
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.h:4641
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition json.h:224
std::size_t size_type
a type to represent container sizes
Definition json.h:216
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.h:1325
wpi::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition json.h:364
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.h:2213
void swap(binary_t &other)
exchanges the values
Definition json.h:3556
ReferenceType get_ref()
get a reference value (implicit)
Definition json.h:1851
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.h:3001
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.h:3425
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.h:1862
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.h:1402
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.h:3217
void push_back(basic_json &&val)
add an object to an array
Definition json.h:3105
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.h:2158
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.h:2907
void dump(raw_ostream &os, const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
Definition json.h:1291
const_reference back() const
access the last element
Definition json.h:2434
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.h:2516
reference operator+=(const basic_json &val)
add an object to an array
Definition json.h:3162
friend 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 &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.h:3496
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.h:4497
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.h:971
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.h:3329
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.h:4581
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.h:239
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.h:2021
iterator end() noexcept
returns an iterator to one past the last element
Definition json.h:2810
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.h:1360
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.h:3432
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.h:4360
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.h:2842
data m_data
Definition json.h:4243
void push_back(initializer_list_t init)
add an object to an object
Definition json.h:3201
::wpi::detail::serializer< basic_json > serializer
Definition json.h:161
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition json.h:801
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.h:1012
ValueType & get_to(ValueType &v) const
Definition json.h:1828
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.h:4299
iterator begin() noexcept
returns an iterator to the first element
Definition json.h:2785
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition json.h:2268
const_iterator cend() const noexcept
returns an iterator to one past the last element
Definition json.h:2826
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.h:4551
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.h:4683
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.h:982
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.h:822
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.h:4385
basic_json flatten() const
return flattened JSON value
Definition json.h:4697
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.h:4512
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.h:2632
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition json.h:340
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition json.h:332
const binary_t & get_binary() const
get a binary value
Definition json.h:1933
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.h:3349
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition json.h:4722
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.h:2321
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition json.h:5003
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.h:4655
value_type & reference
the type of an element reference
Definition json.h:209
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition json.h:173
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.h:2755
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.h:4269
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.h:4376
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition json.h:2668
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.h:960
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.h:2059
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.h:247
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.h:1019
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.h:2682
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.h:4260
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.h:2446
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.h:3302
NumberFloatType number_float_t
a type for a number (floating-point)
Definition json.h:360
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition json.h:2243
AllocatorType< basic_json > allocator_type
the allocator type
Definition json.h:219
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition json.h:222
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition json.h:1271
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.h:5145
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.h:1815
reference operator[](T *key)
Definition json.h:2174
::wpi::json_pointer< StringType > json_pointer
JSON Pointer, see wpi::json_pointer.
Definition json.h:165
reference at(size_type idx)
access specified array element with bounds checking
Definition json.h:1955
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.h:2698
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition json.h:1367
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.h:2849
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.h:4306
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.h:4669
BooleanType boolean_t
a type for a boolean
Definition json.h:348
detail::value_t value_t
Definition json.h:163
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition json.h:327
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.h:3193
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition json.h:2801
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.h:2136
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.h:1573
~basic_json() noexcept
destructor
Definition json.h:1253
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition json.h:2870
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition json.h:901
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.h:3572
binary_t & get_binary()
get a binary value
Definition json.h:1921
friend class ::wpi::detail::parser
Definition json.h:109
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.h:2794
constexpr bool is_number() const noexcept
return whether value is a number
Definition json.h:1346
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.h:3400
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.h:4443
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.h:1802
const_reference operator[](T *key) const
Definition json.h:2180
data(const value_t v)
Definition json.h:4220
reference operator[](size_type idx)
access specified array element
Definition json.h:2077
basic_json(const JsonRef &ref)
Definition json.h:1140
JSONSerializer< T, SFINAE > json_serializer
Definition json.h:167
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
Definition json.h:1230
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.h:4325
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.h:1839
NumberIntegerType number_integer_t
a type for a number (integer)
Definition json.h:352
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.h:1562
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.h:2039
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition json.h:1395
void swap(object_t &other)
exchanges the values
Definition json.h:3524
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.h:4706
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.h:3380
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.h:993
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.h:2900
bool empty() const noexcept
checks whether the container is empty.
Definition json.h:2923
void swap(array_t &other)
exchanges the values
Definition json.h:3508
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.h:2639
reference operator+=(basic_json &&val)
add an object to an array
Definition json.h:3130
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.h:2762
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.h:1311
reference emplace_back(Args &&... args)
add an object to an array
Definition json.h:3226
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.h:2344
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.h:1004
StringType string_t
a type for a string
Definition json.h:344
void push_back(const basic_json &val)
add an object to an array
Definition json.h:3138
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition json.h:2294
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.h:2001
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.h:4566
json_value m_value
the value of the current element
Definition json.h:4218
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition json.h:2863
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition json.h:1339
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.h:2728
reference front()
access the first element
Definition json.h:2411
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.h:1318
constexpr bool is_null() const noexcept
return whether value is null
Definition json.h:1332
void clear() noexcept
clears the contents
Definition json.h:3044
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.h:4317
basic_json(basic_json &&other) noexcept
move constructor
Definition json.h:1213
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition json.h:227
basic_json(const value_t v)
create an empty value with a given type
Definition json.h:814
const_reference operator[](size_type idx) const
access specified array element
Definition json.h:2123
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition json.h:214
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.h:3322
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.h:2856
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition json.h:356
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition json.h:4166
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.h:4283
void swap(string_t &other)
exchanges the values
Definition json.h:3540
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.h:848
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition json.h:231
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.h:1978
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition json.h:368
basic_json(const basic_json &other)
copy constructor
Definition json.h:1144
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.h:3170
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.h:3251
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.h:4276
constexpr bool is_object() const noexcept
return whether value is an object
Definition json.h:1374
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.h:4292
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.h:4458
iterator insert_iterator(const_iterator pos, Args &&... args)
Helper for insertion of an iterator.
Definition json.h:3283
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.h:1031
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.h:2746
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.h:4369
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.h:2714
deserialization of CBOR, MessagePack, and UBJSON values
Definition binary_reader.h:67
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition binary_reader.h:104
general exception of the basic_json class
Definition exceptions.h:39
exception indicating errors with iterators
Definition exceptions.h:190
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition exceptions.h:193
value_type moved_or_copied() const
Definition json_ref.h:53
SAX implementation to create a JSON value from SAX events.
Definition json_sax.h:162
exception indicating other library errors
Definition exceptions.h:242
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition exceptions.h:245
exception indicating access out of the defined range
Definition exceptions.h:225
Definition output_adapters.h:146
exception indicating a parse error
Definition exceptions.h:137
exception indicating executing a member function with a wrong type
Definition exceptions.h:208
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition exceptions.h:211
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json_pointer.h:36
const string_t & back() const
return last reference token
Definition json_pointer.h:171
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition hedley.h:1130
#define JSON_HEDLEY_LIKELY(expr)
Definition hedley.h:1395
#define JSON_HEDLEY_NON_NULL(...)
Definition hedley.h:1288
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition hedley.h:1729
#define JSON_HEDLEY_UNLIKELY(expr)
Definition hedley.h:1396
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition hedley.h:1078
WPI_BASIC_JSON_TPL_DECLARATION std::string to_string(const WPI_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.h:5177
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition json.h:3597
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json_pointer.h:931
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json_pointer.h:981
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json_pointer.h:956
#define WPI_BASIC_JSON_TPL_DECLARATION
Definition macro_scope.h:244
#define JSON_PRIVATE_UNLESS_TESTED
Definition macro_scope.h:207
#define JSON_INTERNAL_CATCH(exception)
Definition macro_scope.h:174
#define JSON_CATCH(exception)
Definition macro_scope.h:173
#define JSON_ASSERT(x)
Definition macro_scope.h:200
#define JSON_THROW(exception)
Definition macro_scope.h:171
#define JSON_TRY
Definition macro_scope.h:172
#define WPI_BASIC_JSON_TPL
Definition macro_scope.h:254
#define JSON_EXPLICIT
Definition macro_scope.h:473
detail namespace with internal helper functions
Definition input_adapters.h:32
input_format_t
the supported input formats
Definition input_adapters.h:35
OutStringType concat(Args &&... args)
Definition string_concat.h:137
typename std::enable_if< B, T >::type enable_if_t
Definition cpp_future.h:38
parse_event_t
Definition parser.h:35
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition type_traits.h:610
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition type_traits.h:183
cbor_tag_handler_t
how to treat CBOR tags
Definition binary_reader.h:40
value_t
the JSON type enumeration
Definition value_t.h:54
@ number_integer
number value (signed integer)
@ binary
binary array (ordered collection of bytes)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition input_adapters.h:380
error_handler_t
how to treat decoding errors
Definition serializer.h:44
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition type_traits.h:597
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition cpp_future.h:24
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition string_escape.h:50
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition parser.h:51
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
WPI_BASIC_JSON_TPL_DECLARATION void swap(wpi::WPI_BASIC_JSON_TPL &j1, wpi::WPI_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< wpi::WPI_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< wpi::WPI_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.h:5258
std::remove_reference< T >::type && move(T &&arg) noexcept
Definition utility.hpp:25
Foonathan namespace.
Definition ntcore_cpp.h:26
constexpr bool operator>(const unexpected< E > &lhs, const unexpected< E > &rhs)
Definition expected:192
array(T, Ts...) -> array< T, 1+sizeof...(Ts)>
constexpr bool operator<=(const unexpected< E > &lhs, const unexpected< E > &rhs)
Definition expected:188
constexpr bool operator>=(const unexpected< E > &lhs, const unexpected< E > &rhs)
Definition expected:196
raw_ostream & operator<<(raw_ostream &OS, sys::TimePoint<> TP)
Definition type_traits.h:247
Definition type_traits.h:114
Definition type_traits.h:139
Definition type_traits.h:50
Definition type_traits.h:768
Definition type_traits.h:564
Definition type_traits.h:534
Definition type_traits.h:260
Definition type_traits.h:122
Definition type_traits.h:621
Definition type_traits.h:554
Definition type_traits.h:790
Definition type_traits.h:254
Definition cpp_future.h:149
SAX interface.
Definition json_sax.h:32
std::size_t operator()(const wpi::WPI_BASIC_JSON_TPL &j) const
Definition json.h:5227
bool operator()(::wpi::detail::value_t lhs, ::wpi::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.h:5241