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>
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;
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>
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(
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)
301#elif defined(__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) {}
458 object = create<object_t>();
464 array = create<array_t>();
470 string = create<string_t>(
"");
476 binary = create<binary_t>();
568 std::vector<basic_json> stack;
573 stack.reserve(
array->size());
574 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
578 stack.reserve(
object->size());
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();
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);
634 AllocatorType<string_t> alloc;
635 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
636 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
642 AllocatorType<binary_t> alloc;
643 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
644 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
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;
718 for (
auto& element : *
m_data.m_value.object)
720 element.second.m_parent =
this;
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,
836 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;
902 bool type_deduction =
true,
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();
922 is_an_object =
false;
938 for (
auto& element_ref : init)
941 m_data.m_value.object->emplace(
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]));
950 m_data.m_value.array = create<array_t>(init.begin(), init.end());
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)
975 res.m_data.m_value =
binary_t(init, subtype);
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)
997 res.m_data.m_value =
binary_t(std::move(init), subtype);
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 >
1055 || !last.m_it.primitive_iterator.is_end()))
1075 m_data.m_value.number_integer =
first.m_object->m_data.m_value.number_integer;
1081 m_data.m_value.number_unsigned =
first.m_object->m_data.m_value.number_unsigned;
1087 m_data.m_value.number_float =
first.m_object->m_data.m_value.number_float;
1093 m_data.m_value.boolean =
first.m_object->m_data.m_value.boolean;
1099 m_data.m_value = *
first.m_object->m_data.m_value.string;
1105 m_data.m_value.object = create<object_t>(
first.m_it.object_iterator,
1106 last.m_it.object_iterator);
1112 m_data.m_value.array = create<array_t>(
first.m_it.array_iterator,
1113 last.m_it.array_iterator);
1119 m_data.m_value = *
first.m_object->m_data.m_value.binary;
1137 template<
typename JsonRef,
1139 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
1145 : json_base_class_t(other)
1149 other.assert_invariant();
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);
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();
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);
1426 return m_data.m_value.boolean;
1451 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
1539 template<
typename ReferenceType,
typename ThisType>
1540 static ReferenceType get_ref_impl(ThisType& 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&&
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,
1626 auto ret = ValueType();
1661 template <
typename ValueType,
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(
1824 template<
typename ValueType,
1835 typename T, std::size_t N,
1836 typename Array = T (&)[N],
1841 std::declval<const basic_json_t&>(), 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&&
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
1916 return get<ValueType>();
1928 return *get_ptr<binary_t*>();
1940 return *get_ptr<const binary_t*>();
1962 return set_parent(
m_data.m_value.array->at(idx));
1985 return m_data.m_value.array->at(idx);
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())
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);
2128 return m_data.m_value.array->operator[](idx);
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);
2163 auto it =
m_data.m_value.object->find(key);
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));
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);
2218 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
2227 template<
typename KeyType>
2231 template<
typename ValueType>
2232 using value_return_type = std::conditional <
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);
2252 return it->template get<ValueType>();
2255 return default_value;
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);
2277 return it->template get<ReturnType>();
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));
2303 return it->template get<ValueType>();
2306 return default_value;
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));
2330 return it->template get<ReturnType>();
2333 return std::forward<ValueType>(default_value);
2343 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
2352 return ptr.get_checked(
this).template get<ValueType>();
2356 return default_value;
2368 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
2377 return ptr.get_checked(
this).template get<ReturnType>();
2381 return std::forward<ValueType>(default_value);
2391 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
2393 ValueType
value(const ::wpi::json_pointer<BasicJsonType>&
ptr,
const ValueType& default_value)
const
2395 return value(
ptr.convert(), default_value);
2402 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
2404 ReturnType
value(const ::wpi::json_pointer<BasicJsonType>&
ptr, ValueType && default_value)
const
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 >
2454 IteratorType result = end();
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;
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;
2492 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
2498 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
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 >
2524 IteratorType result = end();
2536 || !last.m_it.primitive_iterator.is_end()))
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;
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;
2563 result.m_it.object_iterator =
m_data.m_value.object->erase(
first.m_it.object_iterator,
2564 last.m_it.object_iterator);
2570 result.m_it.array_iterator =
m_data.m_value.array->erase(
first.m_it.array_iterator,
2571 last.m_it.array_iterator);
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));
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));
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
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>
2769 bool contains(
const typename ::wpi::json_pointer<BasicJsonType>&
ptr)
const
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);
2923 bool empty() const noexcept
2936 return m_data.m_value.array->empty();
2942 return m_data.m_value.object->empty();
2975 return m_data.m_value.array->size();
2981 return m_data.m_value.object->size();
3008 return m_data.m_value.array->max_size();
3014 return m_data.m_value.object->max_size();
3044 void clear() noexcept
3050 m_data.m_value.number_integer = 0;
3056 m_data.m_value.number_unsigned = 0;
3062 m_data.m_value.number_float = 0.0;
3068 m_data.m_value.boolean =
false;
3074 m_data.m_value.string->clear();
3080 m_data.m_value.binary->clear();
3086 m_data.m_value.array->clear();
3092 m_data.m_value.object->clear();
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);
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);
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>
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)
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;
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);
3438 m_data.m_value.object = create<object_t>();
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
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
3572 void swap(
typename binary_t::container_type& other)
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
3692 return compares_unordered(*
this,
rhs,
inverse);
3696#if JSON_HAS_THREE_WAY_COMPARISON
3702#pragma GCC diagnostic push
3703#pragma GCC diagnostic ignored "-Wfloat-equal"
3708#pragma GCC diagnostic pop
3714 template<
typename ScalarType>
3715 requires std::is_scalar_v<ScalarType>
3725 if (compares_unordered(
rhs,
true))
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
3763 if (compares_unordered(
rhs,
true))
3767 return !(
rhs < *
this);
3772 template<
typename ScalarType>
3773 requires std::is_scalar_v<ScalarType>
3784 if (compares_unordered(
rhs,
true))
3788 return !(*
this <
rhs);
3793 template<
typename ScalarType>
3794 requires std::is_scalar_v<ScalarType>
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>
3826 template<
typename ScalarType,
typename std::enable_if<
3827 std::is_scalar<ScalarType>::value,
int>
::type = 0>
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>
3855 template<
typename ScalarType,
typename std::enable_if<
3856 std::is_scalar<ScalarType>::value,
int>
::type = 0>
3874 template<
typename ScalarType,
typename std::enable_if<
3875 std::is_scalar<ScalarType>::value,
int>
::type = 0>
3883 template<
typename ScalarType,
typename std::enable_if<
3884 std::is_scalar<ScalarType>::value,
int>
::type = 0>
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>
3912 template<
typename ScalarType,
typename std::enable_if<
3913 std::is_scalar<ScalarType>::value,
int>
::type = 0>
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>
3942 template<
typename ScalarType,
typename std::enable_if<
3943 std::is_scalar<ScalarType>::value,
int>
::type = 0>
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>
3971 template<
typename ScalarType,
typename std::enable_if<
3972 std::is_scalar<ScalarType>::value,
int>
::type = 0>
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));
4036 template<
typename InputType>
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>
4055 const bool allow_exceptions =
true,
4056 const bool ignore_comments =
false)
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)
4096 const bool ignore_comments =
false)
4098 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
4103 template <
typename InputType,
typename SAX>
4107 const
bool strict = true,
4108 const
bool ignore_comments = false)
4112 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4118 template<
class IteratorType,
class SAX>
4122 const
bool strict = true,
4123 const
bool ignore_comments = false)
4127 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4136 template <
typename SAX>
4141 const
bool strict = true,
4142 const
bool ignore_comments = false)
4147 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
4228 m_value.array = create<array_t>(cnt, val);
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;
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);
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);
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);
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);
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);
4469 template<
typename T>
4473 const
bool strict = true,
4474 const
bool allow_exceptions = true)
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);
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);
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);
4523 template<
typename T>
4527 const
bool strict = true,
4528 const
bool allow_exceptions = true)
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);
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);
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);
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);
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);
4607 template<
typename T>
4611 const
bool strict = true,
4612 const
bool allow_exceptions = true)
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);
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);
4722 void patch_inplace(
const basic_json& json_patch)
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;
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)
4787 parent[last_path] = val;
4793 if (last_path ==
"-")
4800 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
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));
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,
'\'');
4900 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
4901 const auto path = get_value(op,
"path",
true).template get<std::string>();
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);
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:
4996 result.patch_inplace(json_patch);
5004 const std::string& path =
"")
5020 {
"op",
"replace"}, {
"path", path}, {
"value", target}
5031 while (i <
source.size() && i < target.size())
5035 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
5044 while (i <
source.size())
5057 while (i < target.size())
5063 {
"value", target[i]}
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());
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()}
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())
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);
5244#if JSON_HAS_THREE_WAY_COMPARISON
5245 return std::is_lt(lhs <=> rhs);
5253#ifndef JSON_HAS_CPP_20
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;
or
Definition: ThirdPartyNotices.txt:197
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an exception
Definition: ThirdPartyNotices.txt:290
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 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:112
#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
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
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
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
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
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.h:173
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
const value_type & const_reference
the type of an element const reference
Definition: json.h:211
void swap(binary_t &other)
exchanges the values
Definition: json.h:3556
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.h:1851
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
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition: json.h:3674
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.h:3217
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.h:2158
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
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
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
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition: json.h:3674
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.h:2268
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
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
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or wpi::json_pointer< basic_json::string_t >) reference operator[](const
Definition: json.h:4647
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
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
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.h:340
value_type & reference
the type of an element reference
Definition: json.h:209
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
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
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
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.h:2136
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or wpi::json_pointer< basic_json::string_t >) reference at(const
Definition: json.h:4675
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
detail::out_of_range out_of_range
Definition: json.h:191
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
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
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
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
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:336
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or wpi::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
Definition: json.h:4661
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
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
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or wpi::json_pointer< basic_json::string_t >) ValueType value(const
access the first element
Definition: json.h:2392
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
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
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
Definition: json.h:4105
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
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
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
Definition: json.h:4159
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
Definition: json_ref.h:23
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
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: exceptions.h:228
Definition: output_adapters.h:146
exception indicating a parse error
Definition: exceptions.h:137
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: exceptions.h:149
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
#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
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
basic_json<> json
default specialization
Definition: json_fwd.h:62
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json_pointer.h:981
#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:471
detail namespace with internal helper functions
Definition: chrono.h:321
auto first(const T &value, const Tail &...) -> const T &
Definition: compile.h:62
input_format_t
the supported input formats
Definition: input_adapters.h:35
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: output_adapters.h:47
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: parser.h:52
OutStringType concat(Args &&... args)
Definition: string_concat.h:137
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:603
parse_event_t
Definition: parser.h:35
typename std::enable_if< B, T >::type enable_if_t
Definition: cpp_future.h:38
cbor_tag_handler_t
how to treat CBOR tags
Definition: binary_reader.h:40
@ error
throw a parse_error exception in case of a tag
value_t
the JSON type enumeration
Definition: value_t.h:54
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: hash.h:41
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: input_adapters.h:380
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:615
error_handler_t
how to treat decoding errors
Definition: serializer.h:44
FMT_CONSTEXPR auto copy(InputIt begin, InputIt end, counting_iterator it) -> counting_iterator
Definition: compile.h:25
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: type_traits.h:183
type
Definition: base.h:646
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: cpp_future.h:24
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition: json_custom_base_class.h:36
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: string_escape.h:50
constexpr auto isnan(T value) -> bool
Definition: format.h:2681
WPILIB_DLLEXPORT void from_json(const wpi::json &json, AprilTagFieldLayout &layout)
WPILIB_DLLEXPORT void to_json(wpi::json &json, const AprilTagFieldLayout &layout)
bool operator==(const Value &lhs, const Value &rhs)
Implement std::hash so that hash_code can be used in STL containers.
Definition: array.h:89
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
constexpr bool operator!=(const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
Definition: base.h:2719
constexpr bool operator<=(const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
Definition: base.h:2755
constexpr bool operator>=(const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
Definition: base.h:2731
constexpr bool operator>(const UNIT_LIB_DEFAULT_TYPE lhs, const Units &rhs) noexcept
Definition: base.h:2743
Definition: ntcore_cpp.h:26
array(T, Ts...) -> array< T, 1+sizeof...(Ts)>
auto ptr(const std::unique_ptr< T, Deleter > &p) -> const void *
Definition: std.h:602
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: detected.h:51
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:150
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
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:137