38#define NLOHMANN_JSON_VERSION_MAJOR 3
39#define NLOHMANN_JSON_VERSION_MINOR 1
40#define NLOHMANN_JSON_VERSION_PATCH 2
50#include <initializer_list>
80template<
typename =
void,
typename =
void>
108#if defined(__clang__)
109 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
110 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
112#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
113 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
114 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
119#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
120 #pragma GCC diagnostic push
121 #pragma GCC diagnostic ignored "-Wfloat-equal"
125#if defined(__clang__)
126 #pragma GCC diagnostic push
127 #pragma GCC diagnostic ignored "-Wdocumentation"
131#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
132 #define JSON_THROW(exception) throw exception
134 #define JSON_CATCH(exception) catch(exception)
136 #define JSON_THROW(exception) std::abort()
137 #define JSON_TRY if(true)
138 #define JSON_CATCH(exception) if(false)
142#if defined(JSON_THROW_USER)
144 #define JSON_THROW JSON_THROW_USER
146#if defined(JSON_TRY_USER)
148 #define JSON_TRY JSON_TRY_USER
150#if defined(JSON_CATCH_USER)
152 #define JSON_CATCH JSON_CATCH_USER
156#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
157 #define JSON_LIKELY(x) __builtin_expect(!!(x), 1)
158 #define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
160 #define JSON_LIKELY(x) x
161 #define JSON_UNLIKELY(x) x
174#define NLOHMANN_JSON_HAS_HELPER(type) \
175 template<typename T> struct has_##type { \
177 template<typename U, typename = typename U::type> \
178 static int detect(U &&); \
179 static void detect(...); \
181 static constexpr bool value = \
182 std::is_integral<decltype(detect(std::declval<T>()))>::value; \
201template<
typename>
struct is_json : std::false_type {};
206template<
bool B,
typename T =
void>
222template <
typename T,
typename =
void>
233template<
bool B,
class RealType,
class CompatibleObjectType>
236template<
class RealType,
class CompatibleObjectType>
240 std::is_constructible<std::string_view, typename CompatibleObjectType::key_type>::value
and
241 std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value;
244template<
class BasicJsonType,
class CompatibleObjectType>
248 std::conjunction<std::negation<std::is_same<void, CompatibleObjectType>>,
249 has_mapped_type<CompatibleObjectType>,
250 has_key_type<CompatibleObjectType>>
::value,
251 typename BasicJsonType::object_t, CompatibleObjectType >
::value;
254template<
typename BasicJsonType,
typename T>
257 static auto constexpr value = std::is_same<T, typename BasicJsonType::iterator>::value
or
258 std::is_same<T, typename BasicJsonType::const_iterator>::value
or
259 std::is_same<T, typename BasicJsonType::reverse_iterator>::value
or
260 std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value;
263template<
class BasicJsonType,
class CompatibleArrayType>
267 std::conjunction<std::negation<std::is_same<void, CompatibleArrayType>>,
269 BasicJsonType, CompatibleArrayType>>,
271 CompatibleArrayType>>,
272 std::negation<is_json_nested_type<BasicJsonType, CompatibleArrayType>>,
273 has_value_type<CompatibleArrayType>,
274 has_iterator<CompatibleArrayType>>
::value;
277template<
bool,
typename,
typename>
280template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
288 std::is_constructible<RealIntegerType, CompatibleNumberIntegerType>::value
and
293template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
298 std::is_integral<CompatibleNumberIntegerType>::value
and
299 not std::is_same<bool, CompatibleNumberIntegerType>::value,
300 RealIntegerType, CompatibleNumberIntegerType >
::value;
304template<
typename BasicJsonType,
typename T>
309 template<
typename U,
typename = enable_if_t<std::is_same<
void, decltype(uncvref_t<U>::from_json(
310 std::declval<BasicJsonType>(), std::declval<T&>()))>::value>>
311 static int detect(U&&);
312 static void detect(...);
315 static constexpr bool value = std::is_integral<
decltype(
316 detect(std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>
::value;
321template<
typename BasicJsonType,
typename T>
329 static int detect(U&&);
330 static void detect(...);
333 static constexpr bool value = std::is_integral<
decltype(detect(
334 std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>
::value;
338template<
typename BasicJsonType,
typename T>
342 template<
typename U,
typename = decltype(uncvref_t<U>::to_json(
343 std::declval<BasicJsonType&>(), std::declval<T>()))>
344 static int detect(U&&);
345 static void detect(...);
348 static constexpr bool value = std::is_integral<
decltype(detect(
349 std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>
::value;
352template <
typename BasicJsonType,
typename CompatibleCompleteType>
356 not std::is_base_of<std::istream, CompatibleCompleteType>::value
and
362template <
typename BasicJsonType,
typename CompatibleType>
364 : std::conjunction<is_complete_type<CompatibleType>,
415 const char*
what() const noexcept
override
428 std::runtime_error m;
726 static constexpr std::array<std::uint8_t, 8> order = {{
732 const auto l_index =
static_cast<std::size_t
>(lhs);
733 const auto r_index =
static_cast<std::size_t
>(rhs);
734 return l_index < order.size()
and r_index < order.size()
and order[l_index] < order[r_index];
738template<
typename BasicJsonType,
typename ArithmeticType,
740 not std::is_same<ArithmeticType, bool>::value,
744 switch (
static_cast<value_t>(j))
748 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const uint64_t*>());
753 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const int64_t*>());
758 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const double*>());
767template<
typename BasicJsonType>
774 b = *j.template get_ptr<const bool*>();
777template<
typename BasicJsonType>
784 s = *j.template get_ptr<const std::string*>();
787template<
typename BasicJsonType>
793template<
typename BasicJsonType>
799template<
typename BasicJsonType>
805template<
typename BasicJsonType,
typename EnumType,
811 e =
static_cast<EnumType
>(val);
814template<
typename BasicJsonType>
815void from_json(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr)
821 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
824template<
typename BasicJsonType,
typename CompatibleArrayType>
829 std::transform(j.begin(), j.end(),
830 std::inserter(arr,
end(arr)), [](
const BasicJsonType & i)
834 return i.template get<typename CompatibleArrayType::value_type>();
838template<
typename BasicJsonType,
typename CompatibleArrayType>
841 arr.reserve(std::declval<typename CompatibleArrayType::size_type>()),
846 arr.reserve(j.size());
847 std::transform(j.begin(), j.end(),
848 std::inserter(arr,
end(arr)), [](
const BasicJsonType & i)
852 return i.template get<typename CompatibleArrayType::value_type>();
856template<
typename BasicJsonType,
typename T, std::
size_t N>
859 for (std::size_t i = 0; i < N; ++i)
861 arr[i] = j.at(i).template get<T>();
866 typename BasicJsonType,
typename CompatibleArrayType,
869 not std::is_same<
typename BasicJsonType::array_t,
871 std::is_constructible <
872 BasicJsonType,
typename CompatibleArrayType::value_type >
::value,
874void from_json(
const BasicJsonType& j, CompatibleArrayType& arr)
884template<
typename BasicJsonType>
886void from_json(
const BasicJsonType& j,
typename BasicJsonType::object_t& obj)
893 auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
894 for (
const auto& i : *inner_object) {
895 obj.try_emplace(i.first(), i.second);
899template<
typename BasicJsonType,
typename CompatibleObjectType,
901 not std::is_same<typename BasicJsonType::object_t, CompatibleObjectType>::value,
int> = 0>
902void from_json(
const BasicJsonType& j, CompatibleObjectType& obj)
909 auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
912 using value_type =
typename CompatibleObjectType::value_type;
913 std::vector<value_type> v;
915 for (
const auto& p : *inner_object)
920 .template get<typename CompatibleObjectType::mapped_type>());
925 obj = CompatibleObjectType(std::make_move_iterator(
begin(v)),
926 std::make_move_iterator(
end(v)));
933template<
typename BasicJsonType,
typename ArithmeticType,
935 std::is_arithmetic<ArithmeticType>::value
and
936 not std::is_same<ArithmeticType, uint64_t>::value
and
937 not std::is_same<ArithmeticType, int64_t>::value
and
938 not std::is_same<ArithmeticType, double>::value
and
939 not std::is_same<ArithmeticType, bool>::value,
941void from_json(
const BasicJsonType& j, ArithmeticType& val)
943 switch (
static_cast<value_t>(j))
947 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const uint64_t*>());
952 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const int64_t*>());
957 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const double*>());
962 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const bool*>());
971template<
typename BasicJsonType,
typename A1,
typename A2>
972void from_json(
const BasicJsonType& j, std::pair<A1, A2>& p)
974 p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
977template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
983template<
typename BasicJsonType,
typename... Args>
984void from_json(
const BasicJsonType& j, std::tuple<Args...>& t)
992 template<
typename BasicJsonType,
typename T>
1000 template<
typename BasicJsonType,
typename T>
1001 void call(
const BasicJsonType& , T& ,
priority_tag<0> )
const noexcept
1003 static_assert(
sizeof(BasicJsonType) == 0,
1004 "could not find from_json() method in T's namespace");
1008 static_assert(
sizeof(
typename decayed::force_msvc_stacktrace) == 0,
1009 "forcing MSVC stacktrace to show which T we're talking about.");
1014 template<
typename BasicJsonType,
typename T>
1016 noexcept(
noexcept(std::declval<from_json_fn>().call(j, val,
priority_tag<1> {})))
1042 template<
typename BasicJsonType>
1047 j.assert_invariant();
1054 template<
typename BasicJsonType>
1059 j.assert_invariant();
1062 template<
typename BasicJsonType,
typename T,
1067 j.m_value = std::move(s);
1068 j.assert_invariant();
1075 template<
typename BasicJsonType>
1076 static void construct(BasicJsonType& j,
double val)
noexcept
1080 j.assert_invariant();
1087 template<
typename BasicJsonType>
1092 j.assert_invariant();
1099 template<
typename BasicJsonType>
1104 j.assert_invariant();
1111 template<
typename BasicJsonType>
1112 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
1116 j.assert_invariant();
1119 template<
typename BasicJsonType>
1120 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
1123 j.m_value = std::move(arr);
1124 j.assert_invariant();
1127 template<
typename BasicJsonType,
typename T>
1133 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
1134 j.assert_invariant();
1137 template<
typename BasicJsonType,
typename CompatibleArrayType,
1140 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
1145 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
1146 j.assert_invariant();
1149 template<
typename BasicJsonType>
1150 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
1154 j.m_value.array->reserve(arr.size());
1155 for (
const bool x : arr)
1157 j.m_value.array->push_back(x);
1159 j.assert_invariant();
1166 template<
typename BasicJsonType>
1167 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
1171 j.assert_invariant();
1174 template<
typename BasicJsonType>
1175 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
1178 j.m_value = std::move(obj);
1179 j.assert_invariant();
1182 template<
typename BasicJsonType,
typename CompatibleObjectType,
1184 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
1188 for (
const auto& x : obj)
1190 j.m_value.object->try_emplace(x.first, x.second);
1192 j.assert_invariant();
1200template<
typename BasicJsonType,
typename T,
1207template<
typename BasicJsonType,
typename CompatibleString,
1209void to_json(BasicJsonType& j,
const CompatibleString& s)
1214template<
typename BasicJsonType,
typename T,
1221template<
typename BasicJsonType,
typename FloatType,
1223void to_json(BasicJsonType& j, FloatType val)
noexcept
1228template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
1230void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
1235template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
1237void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
1242template<
typename BasicJsonType,
typename EnumType,
1250template<
typename BasicJsonType>
1251void to_json(BasicJsonType& j,
const std::vector<bool>&
e)
1256template<
typename BasicJsonType,
typename CompatibleArrayType,
1258 std::is_same<typename BasicJsonType::array_t, CompatibleArrayType>::value,
1260void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
1265template<
typename BasicJsonType>
1266void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
1271template<
typename BasicJsonType,
typename CompatibleObjectType,
1273void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
1278template<
typename BasicJsonType>
1279void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
1284template<
typename BasicJsonType,
typename T, std::size_t N,
1291template<
typename BasicJsonType,
typename... Args>
1292void to_json(BasicJsonType& j,
const std::pair<Args...>& p)
1294 j = {p.first, p.second};
1297template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
1300 j = {std::get<Idx>(t)...};
1303template<
typename BasicJsonType,
typename... Args>
1304void to_json(BasicJsonType& j,
const std::tuple<Args...>& t)
1312 template<
typename BasicJsonType,
typename T>
1313 auto call(BasicJsonType& j, T&& val,
priority_tag<1> )
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
1314 ->
decltype(
to_json(j, std::forward<T>(val)), void())
1316 return to_json(j, std::forward<T>(val));
1319 template<
typename BasicJsonType,
typename T>
1322 static_assert(
sizeof(BasicJsonType) == 0,
1323 "could not find to_json() method in T's namespace");
1328 static_assert(
sizeof(
typename decayed::force_msvc_stacktrace) == 0,
1329 "forcing MSVC stacktrace to show which T we're talking about.");
1334 template<
typename BasicJsonType,
typename T>
1336 noexcept(
noexcept(std::declval<to_json_fn>().call(j, std::forward<T>(val),
priority_tag<1> {})))
1363 using difference_type = std::ptrdiff_t;
1364 static constexpr difference_type begin_value = 0;
1365 static constexpr difference_type end_value = begin_value + 1;
1391 return m_it == begin_value;
1397 return m_it == end_value;
1402 return lhs.m_it == rhs.m_it;
1407 return lhs.m_it < rhs.m_it;
1419 return lhs.m_it - rhs.m_it;
1478template<
typename IteratorType>
class iteration_proxy;
1500template<
typename BasicJsonType>
1505 friend BasicJsonType;
1507 friend class ::wpi::JsonTest;
1509 using object_t =
typename BasicJsonType::object_t;
1510 using array_t =
typename BasicJsonType::array_t;
1513 "iter_impl only accepts (const) json");
1529 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
1530 typename BasicJsonType::const_pointer,
1531 typename BasicJsonType::pointer>
::type;
1534 typename std::conditional<std::is_const<BasicJsonType>::value,
1535 typename BasicJsonType::const_reference,
1536 typename BasicJsonType::reference>
::type;
1549 assert(m_object !=
nullptr);
1551 switch (m_object->m_type)
1588 : m_object(other.m_object), m_it(other.m_it) {}
1598 m_object = other.m_object;
1608 void set_begin() noexcept
1610 assert(m_object !=
nullptr);
1612 switch (m_object->m_type)
1645 void set_end() noexcept
1647 assert(m_object !=
nullptr);
1649 switch (m_object->m_type)
1678 assert(m_object !=
nullptr);
1680 switch (m_object->m_type)
1715 assert(m_object !=
nullptr);
1717 switch (m_object->m_type)
1760 assert(m_object !=
nullptr);
1762 switch (m_object->m_type)
1803 assert(m_object !=
nullptr);
1805 switch (m_object->m_type)
1841 assert(m_object !=
nullptr);
1843 switch (m_object->m_type)
1877 assert(m_object !=
nullptr);
1879 switch (m_object->m_type)
1898 return not other.operator < (*this);
1925 assert(m_object !=
nullptr);
1927 switch (m_object->m_type)
1996 assert(m_object !=
nullptr);
1998 switch (m_object->m_type)
2017 assert(m_object !=
nullptr);
2019 switch (m_object->m_type)
2048 assert(m_object !=
nullptr);
2079 class iteration_proxy_internal
2083 IteratorType anchor;
2085 std::size_t array_index = 0;
2088 explicit iteration_proxy_internal(IteratorType it) noexcept : anchor(it) {}
2106 bool operator!=(
const iteration_proxy_internal& o)
const noexcept
2108 return anchor != o.anchor;
2112 std::string key()
const
2114 assert(anchor.m_object !=
nullptr);
2116 switch (anchor.m_object->type())
2124 return std::string{anchor.key()};
2133 typename IteratorType::reference
value()
const
2135 return anchor.
value();
2140 typename IteratorType::reference container;
2145 : container(cont) {}
2148 iteration_proxy_internal
begin() noexcept
2150 return iteration_proxy_internal(container.begin());
2154 iteration_proxy_internal
end() noexcept
2156 return iteration_proxy_internal(container.end());
2182template<
typename Base>
2256 auto it = --this->base();
2263 auto it = --this->base();
2264 return it.operator * ();
2268template<
typename BasicJsonType>
2275 : owned_value(
std::move(
value)), value_ref(&owned_value), is_rvalue(true)
2283 : owned_value(init), value_ref(&owned_value), is_rvalue(true)
2286 template<
class... Args>
2288 : owned_value(
std::forward<Args>(args)...), value_ref(&owned_value), is_rvalue(true)
2300 return std::move(*value_ref);
2307 return *
static_cast<value_type const*
>(value_ref);
2312 return static_cast<value_type const*
>(value_ref);
2318 const bool is_rvalue;
2351 : reference_tokens(
split(s))
2391 std::string pop_back()
2398 auto last = reference_tokens.back();
2399 reference_tokens.pop_back();
2404 bool is_root()
const
2406 return reference_tokens.empty();
2417 result.reference_tokens = {reference_tokens[0]};
2429 json& get_and_create(
json& j)
const;
2507 static void replace_substring(std::string& s,
const std::string& f,
2508 const std::string& t);
2511 static std::string escape(std::string s);
2514 static void unescape(std::string& s);
2543 return (lhs.reference_tokens == rhs.reference_tokens);
2549 return not (lhs == rhs);
2553 std::vector<std::string> reference_tokens;
2556template<
typename,
typename>
2568 template<
typename BasicJsonType,
typename ValueType>
2569 static void from_json(BasicJsonType&& j, ValueType& val)
noexcept(
2584 template<
typename BasicJsonType,
typename ValueType>
2585 static void to_json(BasicJsonType& j, ValueType&& val)
noexcept(
2658 friend ::wpi::json_pointer;
2659 template<
typename BasicJsonType>
2660 friend class ::wpi::detail::iter_impl;
2668 template<
typename BasicJsonType>
2670 template<
typename BasicJsonType>
2672 template<
typename Iterator>
2676 class binary_reader;
2677 class binary_writer;
2687 template<
typename T,
typename SFINAE>
2897 template<
typename T,
typename... Args>
2898 static T* create(Args&& ... args)
2900 std::allocator<T> alloc;
2902 using AllocatorTraits = std::allocator_traits<std::allocator<T>>;
2904 auto deleter = [&](T *
object)
2906 AllocatorTraits::deallocate(alloc,
object, 1);
2908 std::unique_ptr<T,
decltype(deleter)>
object(AllocatorTraits::allocate(alloc, 1), deleter);
2909 AllocatorTraits::construct(alloc,
object.
get(), std::forward<Args>(args)...);
2910 assert(
object !=
nullptr);
2911 return object.release();
2957 double number_float;
2960 json_value() =
default;
2962 json_value(
bool v) noexcept : boolean(v) {}
2964 json_value(
int64_t v) noexcept : number_integer(v) {}
2975 string = create<std::string>(
value);
2979 json_value(
const std::string&
value)
2981 string = create<std::string>(
value);
2985 json_value(std::string&&
value)
2987 string = create<std::string>(std::move(
value));
2993 object = create<object_t>(
value);
2999 object = create<object_t>(std::move(
value));
3014 void destroy(
value_t t)
noexcept;
3026 void assert_invariant() const noexcept
3161 : m_type(v), m_value(v)
3184 json(std::nullptr_t =
nullptr) noexcept
3247 template <
typename CompatibleType,
3251 json(CompatibleType && val)
noexcept(
noexcept(
3253 std::forward<CompatibleType>(val))))
3334 bool type_deduction =
true,
3501 template<
class InputIT,
typename std::enable_if<
3502 std::is_same<InputIT, typename json_t::iterator>::value
or
3503 std::is_same<InputIT, typename json_t::const_iterator>::value,
int>
::type = 0>
3506 assert(
first.m_object !=
nullptr);
3507 assert(
last.m_object !=
nullptr);
3516 m_type =
first.m_object->m_type;
3528 or not
last.m_it.primitive_iterator.is_end()))
3543 m_value.number_integer =
first.m_object->m_value.number_integer;
3549 m_value.number_unsigned =
first.m_object->m_value.number_unsigned;
3555 m_value.number_float =
first.m_object->m_value.number_float;
3561 m_value.boolean =
first.m_object->m_value.boolean;
3567 m_value = *
first.m_object->m_value.string;
3573 m_value.array = create<array_t>(
first.m_it.array_iterator,
3574 last.m_it.array_iterator);
3592 :
json(ref.moved_or_copied())
3649 : m_type(std::move(other.m_type)),
3650 m_value(std::move(other.m_value))
3653 other.assert_invariant();
3656 other.m_type = value_t::null;
3686 std::is_nothrow_move_constructible<value_t>::value
and
3687 std::is_nothrow_move_assignable<value_t>::value
and
3688 std::is_nothrow_move_constructible<json_value>::value
and
3689 std::is_nothrow_move_assignable<json_value>::value
3693 other.assert_invariant();
3696 swap(m_type, other.m_type);
3697 swap(m_value, other.m_value);
3721 m_value.destroy(m_type);
3771 std::string
dump(
const int indent = -1,
const char indent_char =
' ',
3772 const bool ensure_ascii =
false)
const;
3775 const bool ensure_ascii =
false)
const;
3890 return (m_type == value_t::null);
4120 return (m_type == value_t::discarded);
4157 bool get_impl(
bool* )
const
4161 return m_value.boolean;
4170 return is_object() ? m_value.object :
nullptr;
4176 return is_object() ? m_value.object :
nullptr;
4182 return is_array() ? m_value.array :
nullptr;
4188 return is_array() ? m_value.array :
nullptr;
4192 std::string* get_impl_ptr(std::string* )
noexcept
4194 return is_string() ? m_value.string :
nullptr;
4198 const std::string* get_impl_ptr(
const std::string* )
const noexcept
4200 return is_string() ? m_value.string :
nullptr;
4204 bool* get_impl_ptr(
bool* )
noexcept
4206 return is_boolean() ? &m_value.boolean :
nullptr;
4210 const bool* get_impl_ptr(
const bool* )
const noexcept
4212 return is_boolean() ? &m_value.boolean :
nullptr;
4240 double* get_impl_ptr(
double* )
noexcept
4246 const double* get_impl_ptr(
const double* )
const noexcept
4262 template<
typename ReferenceType,
typename ThisType>
4263 static ReferenceType get_ref_impl(ThisType& obj)
4342 template<
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
4343 detail::enable_if_t <
4344 not detail::is_json<ValueType>::value and
4345 detail::has_from_json<json_t, ValueType>::value and
4346 not detail::has_non_default_from_json<json_t, ValueType>::value,
4348 ValueType
get() const noexcept(noexcept(
4354 static_assert(not std::is_reference<ValueTypeCV>::value,
4355 "get() cannot be used with reference types, you might want to use get_ref()");
4356 static_assert(std::is_default_constructible<ValueType>::value,
4357 "types must be DefaultConstructible when used with get()");
4395 template<
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>,
4396 detail::enable_if_t<not std::is_same<json_t, ValueType>::value and
4397 detail::has_non_default_from_json<json_t, ValueType>::value,
4399 ValueType
get() const noexcept(noexcept(
4402 static_assert(not std::is_reference<ValueTypeCV>::value,
4403 "get() cannot be used with reference types, you might want to use get_ref()");
4433 template<
typename PointerType,
typename std::enable_if<
4434 std::is_pointer<PointerType>::value,
int>
::type = 0>
4438 return get_ptr<PointerType>();
4445 template<
typename PointerType,
typename std::enable_if<
4446 std::is_pointer<PointerType>::value,
int>
::type = 0>
4447 const PointerType
get() const noexcept
4450 return get_ptr<PointerType>();
4478 template<
typename PointerType,
typename std::enable_if<
4479 std::is_pointer<PointerType>::value,
int>
::type = 0>
4483 using pointee_t =
typename std::remove_const<
typename
4484 std::remove_pointer<
typename
4488 std::is_same<object_t, pointee_t>::value
4489 or std::is_same<array_t, pointee_t>::value
4490 or std::is_same<std::string, pointee_t>::value
4491 or std::is_same<bool, pointee_t>::value
4492 or std::is_same<int64_t, pointee_t>::value
4493 or std::is_same<uint64_t, pointee_t>::value
4494 or std::is_same<double, pointee_t>::value
4495 ,
"incompatible pointer type");
4498 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
4505 template<
typename PointerType,
typename std::enable_if<
4506 std::is_pointer<PointerType>::value
and
4511 using pointee_t =
typename std::remove_const<
typename
4512 std::remove_pointer<
typename
4516 std::is_same<object_t, pointee_t>::value
4517 or std::is_same<array_t, pointee_t>::value
4518 or std::is_same<std::string, pointee_t>::value
4519 or std::is_same<bool, pointee_t>::value
4520 or std::is_same<int64_t, pointee_t>::value
4521 or std::is_same<uint64_t, pointee_t>::value
4522 or std::is_same<double, pointee_t>::value
4523 ,
"incompatible pointer type");
4526 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
4555 template<
typename ReferenceType,
typename std::enable_if<
4556 std::is_reference<ReferenceType>::value,
int>
::type = 0>
4560 return get_ref_impl<ReferenceType>(*
this);
4567 template<
typename ReferenceType,
typename std::enable_if<
4568 std::is_reference<ReferenceType>::value
and
4573 return get_ref_impl<ReferenceType>(*
this);
4605 template <
typename ValueType,
typename std::enable_if <
4606 not std::is_pointer<ValueType>::value
and
4607 not std::is_same<ValueType, detail::json_ref<json>>
::value and
4608 not std::is_same<ValueType, std::string::value_type>::value
and
4611 and not std::is_same<ValueType, std::initializer_list<std::string::value_type>>
::value
4613 and not std::is_same<ValueType, typename std::string_view>::value
4615 operator ValueType()
const
4618 return get<ValueType>();
4888 template<
typename T>
4902 return m_value.object->operator[](key);
4938 template<
typename T>
4944 assert(m_value.object->find(key) != m_value.object->end());
4945 return m_value.object->find(key)->second;
4999 template<
class ValueType,
typename std::enable_if<
5000 std::is_convertible<json_t, ValueType>::value,
int>
::type = 0>
5007 const auto it =
find(key);
5013 return default_value;
5025 return value(key, std::string(default_value));
5069 template<
class ValueType,
typename std::enable_if<
5070 std::is_convertible<json_t, ValueType>::value,
int>
::type = 0>
5079 return ptr.get_checked(
this);
5083 return default_value;
5096 return value(
ptr, std::string(default_value));
5229 template<
class IteratorType,
typename std::enable_if<
5230 std::is_same<IteratorType, typename json_t::iterator>::value
or
5231 std::is_same<IteratorType, typename json_t::const_iterator>::value,
int>
::type
5249 if (
JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
5256 std::allocator<std::string> alloc;
5257 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
5258 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
5259 m_value.string =
nullptr;
5262 m_type = value_t::null;
5269 m_value.object->erase(pos.m_it.object_iterator);
5275 m_value.array->erase(pos.m_it.array_iterator);
5330 template<
class IteratorType,
typename std::enable_if<
5331 std::is_same<IteratorType, typename json_t::iterator>::value
or
5332 std::is_same<IteratorType, typename json_t::const_iterator>::value,
int>
::type
5353 or not
last.m_it.primitive_iterator.is_end()))
5360 std::allocator<std::string> alloc;
5361 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
5362 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
5363 m_value.string =
nullptr;
5366 m_type = value_t::null;
5373 result.m_it.array_iterator = m_value.array->erase(
first.m_it.array_iterator,
5374 last.m_it.array_iterator);
6109 template<
typename T,
typename U>
6127 m_value.object->try_emplace(val.first, std::move(val.second));
6134 template<
typename T,
typename U>
6199 template<
class... Args>
6217 m_value.array->emplace_back(std::forward<Args>(args)...);
6247 template<
class... Args>
6265 auto res = m_value.object->try_emplace(key, std::forward<Args>(args)...);
6268 it.m_it.object_iterator = res.first;
6271 return {it, res.second};
6483 std::is_nothrow_move_constructible<value_t>::value
and
6484 std::is_nothrow_move_assignable<value_t>::value
and
6485 std::is_nothrow_move_constructible<json_value>::value
and
6486 std::is_nothrow_move_assignable<json_value>::value
6648 template<
typename ScalarType,
typename std::enable_if<
6649 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6652 return (lhs ==
json(rhs));
6659 template<
typename ScalarType,
typename std::enable_if<
6660 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6663 return (
json(lhs) == rhs);
6686 return not (lhs == rhs);
6693 template<
typename ScalarType,
typename std::enable_if<
6694 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6697 return (lhs !=
json(rhs));
6704 template<
typename ScalarType,
typename std::enable_if<
6705 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6708 return (
json(lhs) != rhs);
6743 template<
typename ScalarType,
typename std::enable_if<
6744 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6747 return (lhs <
json(rhs));
6754 template<
typename ScalarType,
typename std::enable_if<
6755 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6758 return (
json(lhs) < rhs);
6782 return not (rhs < lhs);
6789 template<
typename ScalarType,
typename std::enable_if<
6790 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6793 return (lhs <=
json(rhs));
6800 template<
typename ScalarType,
typename std::enable_if<
6801 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6804 return (
json(lhs) <= rhs);
6828 return not (lhs <= rhs);
6835 template<
typename ScalarType,
typename std::enable_if<
6836 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6839 return (lhs >
json(rhs));
6846 template<
typename ScalarType,
typename std::enable_if<
6847 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6850 return (
json(lhs) > rhs);
6874 return not (lhs < rhs);
6881 template<
typename ScalarType,
typename std::enable_if<
6882 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6885 return (lhs >=
json(rhs));
6892 template<
typename ScalarType,
typename std::enable_if<
6893 std::is_scalar<ScalarType>::value,
int>
::type = 0>
6896 return (
json(lhs) >= rhs);
7015 const bool allow_exceptions =
true);
7019 const bool allow_exceptions =
true);
7026 const bool allow_exceptions =
true);
7030 static bool accept(std::span<const uint8_t> arr);
7109 json_value m_value = {};
7208 static std::span<uint8_t>
to_cbor(
const json& j, std::vector<uint8_t>& buf);
7378 const bool use_size =
false,
7379 const bool use_type =
false);
7381 const bool use_size =
false,
const bool use_type =
false);
7383 const bool use_size =
false,
const bool use_type =
false);
7385 const bool use_size =
false,
const bool use_type =
false);
7481 const bool strict =
true);
7562 const bool strict =
true);
7623 const bool strict =
true);
7671 return ptr.get_unchecked(
this);
7699 return ptr.get_unchecked(
this);
7742 return ptr.get_checked(
this);
7785 return ptr.get_checked(
this);
7813 json_pointer::flatten(
"", *
this,
result);
7849 return json_pointer::unflatten(*
this);
7944 const std::string& path =
"");
8018 is_nothrow_move_constructible<wpi::json>::value
and
8019 is_nothrow_move_assignable<wpi::json>::value
8037 const auto&
h = hash<std::string>();
8074inline wpi::json operator "" _json(
const char* s, std::size_t n)
8097#ifndef WPI_JSON_IMPLEMENTATION
8100#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
8101 #pragma GCC diagnostic pop
8103#if defined(__clang__)
8104 #pragma GCC diagnostic pop
8113#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
8114#undef NLOHMANN_BASIC_JSON_TPL
8115#undef NLOHMANN_JSON_HAS_HELPER
EIGEN_DEVICE_FUNC const NegativeReturnType operator-() const
Definition: CommonCwiseUnaryOps.h:45
This file defines the StringMap class.
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
or
Definition: ThirdPartyNotices.txt:199
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:292
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:114
constexpr FMT_INLINE value()
Definition: core.h:1263
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:114
This class is a wrapper around std::array that does compile time size checking.
Definition: array.h:25
general exception of the json class
Definition: json.h:412
exception(int id_, std::string_view what_arg)
const char * what() const noexcept override
returns the explanatory string
Definition: json.h:415
const int id
the id of the exception
Definition: json.h:421
exception indicating errors with iterators
Definition: json.h:541
static invalid_iterator create(int id_, std::string_view what_arg)
static invalid_iterator create(int id_, std::string_view what_arg, std::string_view type_info)
a template for a bidirectional iterator for the json class
Definition: json.h:1502
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.h:1527
std::string_view key() const
return the key of an object iterator
Definition: json.h:2046
iter_impl()=default
default constructor
Definition: json.h:1504
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.h:1596
reference operator[](difference_type n) const
access to successor
Definition: json.h:2015
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.h:1896
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.h:1676
iter_impl & operator++()
pre-increment (++it)
Definition: json.h:1758
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.h:1587
iter_impl const operator++(int)
post-increment (it++)
Definition: json.h:1747
iter_impl const operator--(int)
post-decrement (it–)
Definition: json.h:1790
iter_impl & operator--()
pre-decrement (–it)
Definition: json.h:1801
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.h:1525
pointer operator->() const
dereference the iterator
Definition: json.h:1713
iter_impl(pointer object) noexcept
constructor for a given JSON instance
Definition: json.h:1547
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.h:1914
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.h:1536
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.h:1972
reference value() const
return the value of an iterator
Definition: json.h:2062
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.h:1983
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.h:1905
bool operator==(const iter_impl &other) const
comparison: equal
Definition: json.h:1833
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.h:1869
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.h:1994
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.h:1961
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.h:1923
std::bidirectional_iterator_tag iterator_category
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
Definition: json.h:1522
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.h:1952
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.h:1531
bool operator!=(const iter_impl &other) const
comparison: not equal
Definition: json.h:1860
proxy class for the items() function
Definition: json.h:2076
iteration_proxy_internal begin() noexcept
return iterator begin (needed for range-based for)
Definition: json.h:2148
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.h:2144
iteration_proxy_internal end() noexcept
return iterator end (needed for range-based for)
Definition: json.h:2154
value_type const & operator*() const
Definition: json.h:2305
json_ref(Args &&... args)
Definition: json.h:2287
json_ref(std::initializer_list< json_ref > init)
Definition: json.h:2282
json_ref & operator=(const json_ref &)=delete
json_ref(value_type &&value)
Definition: json.h:2274
value_type moved_or_copied() const
Definition: json.h:2296
value_type const * operator->() const
Definition: json.h:2310
json_ref(const value_type &value)
Definition: json.h:2278
BasicJsonType value_type
Definition: json.h:2272
json_ref(const json_ref &)=delete
json_ref(json_ref &&)=default
a template for a reverse iterator class
Definition: json.h:2184
reference operator[](difference_type n) const
access to successor
Definition: json.h:2248
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.h:2206
json_reverse_iterator const operator++(int)
post-increment (it++)
Definition: json.h:2200
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.h:2230
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.h:2254
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.h:2188
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.h:2236
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.h:2242
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.h:2218
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.h:2193
reference value() const
return the value of an iterator
Definition: json.h:2261
std::ptrdiff_t difference_type
Definition: json.h:2186
json_reverse_iterator const operator--(int)
post-decrement (it–)
Definition: json.h:2212
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.h:2197
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.h:2190
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.h:2224
exception indicating other library errors
Definition: json.h:665
static other_error create(int id_, std::string_view what_arg)
exception indicating access out of the defined range
Definition: json.h:632
static out_of_range create(int id_, std::string_view what_arg)
exception indicating a parse error
Definition: json.h:475
static parse_error create(int id_, std::size_t byte_, std::string_view what_arg)
create a parse error exception
const std::size_t byte
byte index of the parse error
Definition: json.h:496
primitive_iterator_t & operator--() noexcept
Definition: json.h:1435
constexpr difference_type get_value() const noexcept
Definition: json.h:1371
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.h:1377
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.h:1410
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.h:1448
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.h:1395
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.h:1389
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.h:1405
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.h:1454
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.h:1400
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.h:1417
primitive_iterator_t const operator++(int) noexcept
Definition: json.h:1428
primitive_iterator_t const operator--(int) noexcept
Definition: json.h:1441
primitive_iterator_t & operator++() noexcept
Definition: json.h:1422
void set_end() noexcept
set iterator to a defined past the end
Definition: json.h:1383
exception indicating executing a member function with a wrong type
Definition: json.h:590
static type_error create(int id_, std::string_view what_arg)
static type_error create(int id_, std::string_view what_arg, std::string_view type_info)
Definition: json_serializer.h:45
static int array_index(std::string_view s)
std::string to_string() const noexcept
return a string representation of the JSON pointer
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
Definition: json.h:2540
friend class JsonTest
Definition: json.h:2326
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
Definition: json.h:2546
friend class json
Definition: json.h:2325
json_pointer(std::string_view s={})
create JSON pointer
Definition: json.h:2350
a class to store JSON values
Definition: json.h:2655
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.h:4557
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition: json.h:5841
const_reference operator[](size_type idx) const
access specified array element
std::allocator< json > allocator_type
the allocator type
Definition: json.h:2739
PointerType get() noexcept
get a pointer value (explicit)
Definition: json.h:4435
iterator insert(const_iterator pos, const json &val)
inserts element
static json from_cbor(std::span< const uint8_t > arr, const bool strict=true)
create a JSON value from an input in CBOR format
bool is_number() const noexcept
return whether value is a number
Definition: json.h:3940
void swap(object_t &other)
exchanges the values
Definition: json.h:6547
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.h:4570
std::vector< json > array_t
a type for an array
Definition: json.h:2890
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.h:6848
bool empty() const noexcept
checks whether the container is empty.
void push_back(initializer_list_t init)
add an object to an object
json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.h:3184
void update(const_reference j)
updates a JSON object from another object, overwriting existing keys
size_type size() const noexcept
returns the number of elements
const_reference operator[](T *key) const
read-only access specified object element
Definition: json.h:4939
static json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.h:3374
iterator begin() noexcept
returns an iterator to the first element
Definition: json.h:5539
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.h:7697
const_iterator begin() const noexcept
returns a const iterator to the first element
Definition: json.h:5549
const_iterator cend() const noexcept
returns a const iterator to one past the last element
Definition: json.h:5650
json(size_type cnt, const json &val)
construct an array with count copies of given value
reference front()
access the first element
Definition: json.h:5124
json get() const
get special-case overload
Definition: json.h:4298
ValueType get() const noexcept(noexcept(adl_serializer< ValueType, void >::from_json(std::declval< const json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition: json.h:4348
static std::vector< uint8_t > to_cbor(const json &j)
create a CBOR serialization of a given JSON value
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
void push_back(json &&val)
add an object to an array
bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.h:3969
reference at(std::string_view key)
access specified object element with bounds checking
reference operator[](std::string_view key)
access specified object element
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.h:5725
detail::value_t value_t
Definition: json.h:2684
friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
comparison: greater than
Definition: json.h:6837
static bool accept(std::string_view s)
static std::span< uint8_t > to_msgpack(const json &j, std::vector< uint8_t > &buf)
iterator insert(const_iterator pos, json &&val)
inserts element
Definition: json.h:6302
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition: json.h:5849
json(const value_t v)
create an empty value with a given type
Definition: json.h:3160
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.h:7740
friend class JsonTest
Definition: json.h:2661
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.h:5071
const_reference front() const
access the first element
Definition: json.h:5132
static std::vector< uint8_t > to_msgpack(const json &j)
create a MessagePack serialization of a given JSON value
void push_back(const std::pair< T, U > &val)
add an object to an object
Definition: json.h:6110
static json parse(std::string_view s, const parser_callback_t cb=nullptr, const bool allow_exceptions=true)
deserialize from a compatible input
json(CompatibleType &&val) noexcept(noexcept(adl_serializer< U, void >::to_json(std::declval< json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value
Definition: json.h:3251
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition: json.h:5680
size_type erase(std::string_view key)
remove element from a JSON object given a key
bool is_primitive() const noexcept
return whether type is primitive
Definition: json.h:3839
value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.h:3809
void push_back(const json &val)
add an object to an array
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements
void merge_patch(const json &patch)
applies a JSON Merge Patch
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.h:6780
reference back()
access the last element
Definition: json.h:5168
friend raw_ostream & operator<<(raw_ostream &o, const json &j)
serialize to stream
StringMap< json > object_t
a type for an object
Definition: json.h:2863
friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.h:6894
iterator insert(const_iterator pos, size_type cnt, const json &val)
inserts elements
std::string dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false) const
serialization
static json from_ubjson(std::span< const uint8_t > arr, const bool strict=true)
void swap(std::string &other)
exchanges the values
Definition: json.h:6580
json patch(const json &json_patch) const
applies a JSON patch
void emplace_back(Args &&... args)
add an object to an array
Definition: json.h:6200
bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.h:4025
std::initializer_list< detail::json_ref< json > > initializer_list_t
helper type for initializer lists of json values
Definition: json.h:2690
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
void update(const_iterator first, const_iterator last)
updates a JSON object from another object, overwriting existing keys
friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
comparison: greater than or equal
Definition: json.h:6883
const_reference at(size_type idx) const
access specified array element with bounds checking
PointerType get_ptr() noexcept
get a pointer value (implicit)
Definition: json.h:4480
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.h:6684
static std::span< uint8_t > to_cbor(const json &j, std::vector< uint8_t > &buf)
bool is_structured() const noexcept
return whether type is structured
Definition: json.h:3866
const char * type_name() const noexcept
return the type as string
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.h:6872
std::less<> object_comparator_t
Definition: json.h:2806
bool is_discarded() const noexcept
return whether value is discarded
Definition: json.h:4118
friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
comparison: less than
Definition: json.h:6745
static json diff(const json &source, const json &target, const std::string &path="")
creates a diff as a JSON patch
static std::vector< uint8_t > to_ubjson(const json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
reference operator+=(const json &val)
add an object to an array
Definition: json.h:6083
friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
comparison: less than or equal
Definition: json.h:6791
static std::span< uint8_t > to_ubjson(const json &j, SmallVectorImpl< uint8_t > &buf, const bool use_size=false, const bool use_type=false)
static std::span< uint8_t > to_ubjson(const json &j, std::vector< uint8_t > &buf, const bool use_size=false, const bool use_type=false)
void clear() noexcept
clears the contents
reference operator+=(const std::pair< T, U > &val)
add an object to an object
Definition: json.h:6135
const_iterator end() const noexcept
returns a const iterator to one past the last element
Definition: json.h:5620
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.h:5610
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.h:6826
void swap(array_t &other)
exchanges the values
Definition: json.h:6514
void erase(IteratorType pos)
remove element given an iterator
Definition: json.h:5233
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.h:5783
size_type count(std::string_view key) const
returns the number of occurrences of a key in a JSON object
parse_event_t
parser event types
Definition: json.h:3054
reference & operator=(json other) noexcept(std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition: json.h:3685
static bool accept(raw_istream &i)
json unflatten() const
unflatten a previously flattened JSON value
Definition: json.h:7847
static void to_cbor(raw_ostream &os, const json &j)
json(json &&other) noexcept
move constructor
Definition: json.h:3648
reference at(size_type idx)
access specified array element with bounds checking
static void to_msgpack(raw_ostream &os, const json &j)
const_reference back() const
access the last element
Definition: json.h:5178
json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.h:3504
reference operator[](T *key)
access specified object element
Definition: json.h:4889
friend raw_istream & operator>>(raw_istream &i, json &j)
deserialize from stream
bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.h:3910
const_iterator find(std::string_view key) const
find an element in a JSON object
void insert(const_iterator first, const_iterator last)
inserts elements
static json parse(std::span< const uint8_t > arr, const parser_callback_t cb=nullptr, const bool allow_exceptions=true)
void erase(const size_type idx)
remove element from a JSON array given an index
std::size_t size_type
a type to represent container sizes
Definition: json.h:2736
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
size_type max_size() const noexcept
returns the maximum possible number of elements
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.h:2761
friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.h:6706
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.h:7783
std::string value(std::string_view key, const char *default_value) const
overload for a default value of type const char*
Definition: json.h:5023
static std::span< uint8_t > to_msgpack(const json &j, SmallVectorImpl< uint8_t > &buf)
json_reverse_iterator< typename json::iterator > reverse_iterator
a reverse iterator for a json container
Definition: json.h:2751
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.h:7669
iterator find(std::string_view key)
find an element in a JSON object
static std::span< uint8_t > to_cbor(const json &j, SmallVectorImpl< uint8_t > &buf)
static json from_msgpack(std::span< const uint8_t > arr, const bool strict=true)
create a JSON value from an input in MessagePack format
friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
comparison: equal
Definition: json.h:6650
const_reference at(std::string_view key) const
access specified object element with bounds checking
friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.h:6756
~json() noexcept
destructor
Definition: json.h:3718
static json from_msgpack(raw_istream &is, const bool strict=true)
create a JSON value from an input in MessagePack format
const PointerType get_ptr() const noexcept
get a pointer value (implicit)
Definition: json.h:4508
static json from_ubjson(raw_istream &is, const bool strict=true)
create a JSON value from an input in UBJSON format
json flatten() const
return flattened JSON value
Definition: json.h:7810
bool is_array() const noexcept
return whether value is an array
Definition: json.h:4069
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.h:2734
static json from_cbor(raw_istream &is, const bool strict=true)
create a JSON value from an input in CBOR format
const PointerType get() const noexcept
get a pointer value (explicit)
Definition: json.h:4447
void dump(raw_ostream &os, int indent=-1, const char indent_char=' ', const bool ensure_ascii=false) const
static bool accept(std::span< const uint8_t > arr)
static json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.h:3417
std::function< bool(int depth, parse_event_t event, json &parsed)> parser_callback_t
per-element parser callback type
Definition: json.h:3119
bool is_null() const noexcept
return whether value is null
Definition: json.h:3888
static json parse(raw_istream &i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true)
create an empty value with a given type parse(raw_istream&, const parser_callback_t)
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition: json.h:5579
const_reference operator[](std::string_view key) const
read-only access specified object element
friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.h:6802
ValueType get() const noexcept(noexcept(adl_serializer< ValueTypeCV, void >::from_json(std::declval< const json_t & >())))
get a value (explicit); special case
Definition: json.h:4399
bool is_object() const noexcept
return whether value is an object
Definition: json.h:4047
bool is_string() const noexcept
return whether value is a string
Definition: json.h:4091
std::string value(const json_pointer &ptr, const char *default_value) const
overload for a default value of type const char*
Definition: json.h:5094
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.h:6172
::wpi::json_pointer json_pointer
Definition: json.h:2686
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.h:5754
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.h:6482
std::pair< iterator, bool > emplace(std::string_view key, Args &&... args)
add an object to an object if key does not exist
Definition: json.h:6248
bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.h:3997
reference operator[](size_type idx)
access specified array element
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition: json.h:5717
json_reverse_iterator< typename json::const_iterator > const_reverse_iterator
a const reverse iterator for a json container
Definition: json.h:2753
static void to_ubjson(raw_ostream &os, const json &j, const bool use_size=false, const bool use_type=false)
json(const json &other)
copy constructor
friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.h:6661
ValueType value(std::string_view key, const ValueType &default_value) const
access specified object element with default value
Definition: json.h:5001
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.h:5334
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.h:5688
friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
comparison: not equal
Definition: json.h:6695
static json meta()
returns version information on the library
Definition: raw_istream.h:22
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:44
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:298
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
Can be used as a parameter to Eigen::seq and Eigen::seqN functions to symbolically reference the last...
Definition: IndexedViewHelper.h:38
#define JSON_LIKELY(x)
Definition: json.h:160
#define JSON_CATCH(exception)
Definition: json.h:138
#define JSON_THROW(exception)
Definition: json.h:136
#define JSON_TRY
Definition: json.h:137
#define JSON_UNLIKELY(x)
Definition: json.h:161
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:81
::uint64_t uint64_t
Definition: Meta.h:58
::int64_t int64_t
Definition: Meta.h:59
::uint8_t uint8_t
Definition: Meta.h:52
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
result
Definition: format.h:2556
GHC_FS_API directory_iterator begin(directory_iterator iter) noexcept
Definition: filesystem.hpp:5746
Definition: StdDeque.h:50
void swap(wpi::SmallVectorImpl< T > &LHS, wpi::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1299
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
static constexpr const charge::coulomb_t e(1.6021766208e-19)
elementary charge.
std::string to_string(const T &t)
Definition: base.h:93
unit_t< Units, T, NonLinearScale > & operator+=(unit_t< Units, T, NonLinearScale > &lhs, const RhsType &rhs) noexcept
Definition: base.h:2281
unit_t< Units, T, NonLinearScale > & operator++(unit_t< Units, T, NonLinearScale > &u) noexcept
Definition: base.h:2335
unit_t< Units, T, NonLinearScale > & operator--(unit_t< Units, T, NonLinearScale > &u) noexcept
Definition: base.h:2359
constexpr unit_t< Units, T, NonLinearScale > operator+(const unit_t< Units, T, NonLinearScale > &u) noexcept
Definition: base.h:2328
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.h:1202
value_t
the JSON type enumeration
Definition: json.h:702
@ number_integer
number value (signed integer)
@ discarded
discarded by the the parser callback function
@ 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)
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.h:742
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, std::index_sequence< Idx... >)
Definition: json.h:1298
NLOHMANN_JSON_HAS_HELPER(mapped_type)
void from_json_array_impl(const BasicJsonType &j, CompatibleArrayType &arr, priority_tag< 0 >)
Definition: json.h:825
void from_json(const BasicJsonType &j, bool &b)
Definition: json.h:768
void to_json(BasicJsonType &j, const std::tuple< Args... > &t)
Definition: json.h:1304
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.h:210
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.h:724
void from_json(const BasicJsonType &j, std::tuple< Args... > &t)
Definition: json.h:984
void from_json_tuple_impl(const BasicJsonType &j, Tuple &t, std::index_sequence< Idx... >)
Definition: json.h:978
typename std::enable_if< B, T >::type enable_if_t
Definition: json.h:207
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
bool operator!=(PointerUnion< PTs... > lhs, PointerUnion< PTs... > rhs)
Definition: PointerUnion.h:244
constexpr std::pair< std::string_view, std::string_view > split(std::string_view str, char separator) noexcept
Splits str into two substrings around the first occurrence of a separator character.
Definition: StringExtras.h:438
std::size_t operator()(const wpi::json &j) const
return a hash value for a JSON object
Definition: json.h:8034
bool operator()(wpi::detail::value_t lhs, wpi::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.h:8052
default JSONSerializer template argument
Definition: json.h:2558
static void to_json(BasicJsonType &j, ValueType &&val) noexcept(noexcept(::wpi::to_json(j, std::forward< ValueType >(val))))
convert any value type to a JSON value
Definition: json.h:2585
static void from_json(BasicJsonType &&j, ValueType &val) noexcept(noexcept(::wpi::from_json(std::forward< BasicJsonType >(j), val)))
convert a JSON value to any value type
Definition: json.h:2569
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.h:1120
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.h:1140
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.h:1150
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.h:1112
static void construct(BasicJsonType &j, std::span< T > arr)
Definition: json.h:1128
static void construct(BasicJsonType &j, bool b) noexcept
Definition: json.h:1043
static void construct(BasicJsonType &j, double val) noexcept
Definition: json.h:1076
static void construct(BasicJsonType &j, int64_t val) noexcept
Definition: json.h:1100
static void construct(BasicJsonType &j, uint64_t val) noexcept
Definition: json.h:1088
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.h:1167
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.h:1175
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.h:1184
static void construct(BasicJsonType &j, std::string_view s)
Definition: json.h:1055
static void construct(BasicJsonType &j, T &&s)
Definition: json.h:1064
void operator()(const BasicJsonType &j, T &val) const noexcept(noexcept(std::declval< from_json_fn >().call(j, val, priority_tag< 1 > {})))
Definition: json.h:1015
an iterator value
Definition: json.h:1468
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.h:1474
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.h:1472
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.h:1470
static auto constexpr value
Definition: json.h:266
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.h:284
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.h:285
static constexpr auto value
Definition: json.h:296
static auto constexpr value
Definition: json.h:247
static constexpr T value
Definition: json.h:373
void operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(std::declval< to_json_fn >().call(j, std::forward< T >(val), priority_tag< 1 > {})))
Definition: json.h:1335
constexpr T & get(wpi::array< T, N > &arr) noexcept
Definition: array.h:66