13#include <forward_list>  
   19#include <unordered_map>  
   36template<
typename BasicJsonType>
 
   37inline void from_json(
const BasicJsonType& j, 
typename std::nullptr_t& n)
 
 
   47template < 
typename BasicJsonType, 
typename ArithmeticType,
 
   48           enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
 
   49                         !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
 
   53    switch (
static_cast<value_t>(j))
 
   57            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
 
   62            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
 
   67            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
 
 
   83template<
typename BasicJsonType>
 
   84inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::boolean_t& b)
 
   90    b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
 
 
   93template<
typename BasicJsonType>
 
   94inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::string_t& s)
 
  100    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
 
 
  104    typename BasicJsonType, 
typename StringType,
 
  106        std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
 
  107        && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
 
  108        && !std::is_same<typename BasicJsonType::string_t, StringType>::value
 
  109        && !is_json_ref<StringType>::value, 
int > = 0 >
 
  110inline void from_json(
const BasicJsonType& j, StringType& s)
 
  117    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
 
 
  120template<
typename BasicJsonType>
 
  121inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::number_float_t& val)
 
 
  126template<
typename BasicJsonType>
 
  127inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::number_unsigned_t& val)
 
 
  132template<
typename BasicJsonType>
 
  133inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::number_integer_t& val)
 
 
  138#if !JSON_DISABLE_ENUM_SERIALIZATION 
  139template<
typename BasicJsonType, 
typename EnumType,
 
  141inline void from_json(
const BasicJsonType& j, EnumType& e)
 
  143    typename std::underlying_type<EnumType>::type val;
 
  145    e = 
static_cast<EnumType
>(val);
 
 
  150template<
typename BasicJsonType, 
typename T, 
typename Allocator,
 
  152inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
 
  159    std::transform(j.rbegin(), j.rend(),
 
  160                   std::front_inserter(l), [](
const BasicJsonType & i)
 
  162        return i.template get<T>();
 
 
  167template<
typename BasicJsonType, 
typename T,
 
  169inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
 
  176    std::transform(j.begin(), j.end(), std::begin(l),
 
  177                   [](
const BasicJsonType & elem)
 
  179        return elem.template get<T>();
 
 
  183template<
typename BasicJsonType, 
typename T, std::
size_t N>
 
  185-> 
decltype(j.template 
get<T>(), void())
 
  187    for (std::size_t i = 0; i < N; ++i)
 
  189        arr[i] = j.at(i).template 
get<T>();
 
 
  193template<
typename BasicJsonType>
 
  196    arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
 
 
  199template<
typename BasicJsonType, 
typename T, std::
size_t N>
 
  202-> 
decltype(j.template 
get<T>(), void())
 
  204    for (std::size_t i = 0; i < N; ++i)
 
  206        arr[i] = j.at(i).template 
get<T>();
 
 
  210template<
typename BasicJsonType, 
typename ConstructibleArrayType,
 
  212             std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
 
  216    arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
 
  217    j.template get<typename ConstructibleArrayType::value_type>(),
 
  222    ConstructibleArrayType ret;
 
  223    ret.reserve(j.size());
 
  224    std::transform(j.begin(), j.end(),
 
  225                   std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
 
  231    arr = std::move(ret);
 
 
  234template<
typename BasicJsonType, 
typename ConstructibleArrayType,
 
  236             std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
 
  243    ConstructibleArrayType ret;
 
  245        j.begin(), j.end(), std::inserter(ret, end(ret)),
 
  246        [](
const BasicJsonType & i)
 
  252    arr = std::move(ret);
 
 
  255template < 
typename BasicJsonType, 
typename ConstructibleArrayType,
 
  257               is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
 
  258               !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
 
  260               !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
 
  261               !is_basic_json<ConstructibleArrayType>::value,
 
  263auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
 
  265j.template get<typename ConstructibleArrayType::value_type>(),
 
 
  276template < 
typename BasicJsonType, 
typename T, std::size_t... Idx >
 
  280    return { { std::forward<BasicJsonType>(j).at(Idx).template 
get<T>()... } };
 
 
  283template < 
typename BasicJsonType, 
typename T, std::
size_t N >
 
  295template<
typename BasicJsonType>
 
  296inline void from_json(
const BasicJsonType& j, 
typename BasicJsonType::binary_t& 
bin)
 
  303    bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
 
 
  306template<
typename BasicJsonType, 
typename ConstructibleObjectType,
 
  308inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
 
  315    ConstructibleObjectType ret;
 
  316    const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
 
  317    using value_type = 
typename ConstructibleObjectType::value_type;
 
  319        inner_object->begin(), inner_object->end(),
 
  320        std::inserter(ret, ret.begin()),
 
  321        [](
typename BasicJsonType::object_t::value_type 
const & p)
 
  323        return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
 
  325    obj = std::move(ret);
 
 
  332template < 
typename BasicJsonType, 
typename ArithmeticType,
 
  334               std::is_arithmetic<ArithmeticType>::value&&
 
  335               !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
 
  336               !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
 
  337               !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
 
  338               !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
 
  340inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
 
  342    switch (
static_cast<value_t>(j))
 
  346            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
 
  351            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
 
  356            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
 
  361            val = 
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
 
 
  376template<
typename BasicJsonType, 
typename... Args, std::size_t... Idx>
 
  379    return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
 
 
  382template < 
typename BasicJsonType, 
class A1, 
class A2 >
 
  385    return {std::forward<BasicJsonType>(j).at(0).template 
get<A1>(),
 
  386            std::forward<BasicJsonType>(j).at(1).template 
get<A2>()};
 
 
  389template<
typename BasicJsonType, 
typename A1, 
typename A2>
 
  395template<
typename BasicJsonType, 
typename... Args>
 
  401template<
typename BasicJsonType, 
typename... Args>
 
  407template<
typename BasicJsonType, 
typename TupleRelated>
 
  416    return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
 
 
  419template < 
typename BasicJsonType, 
typename Key, 
typename Value, 
typename Compare, 
typename Allocator,
 
  421                                        typename BasicJsonType::string_t, Key >
::value >>
 
  422inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
 
  429    for (
const auto& p : j)
 
  435        m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
 
 
  439template < 
typename BasicJsonType, 
typename Key, 
typename Value, 
typename Hash, 
typename KeyEqual, 
typename Allocator,
 
  441                                        typename BasicJsonType::string_t, Key >
::value >>
 
  442inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
 
  449    for (
const auto& p : j)
 
  455        m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
 
 
  459#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM 
  460template<
typename BasicJsonType>
 
  461inline void from_json(
const BasicJsonType& j, std_fs::path& p)
 
  467    p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
 
  473    template<
typename BasicJsonType, 
typename T>
 
  475    noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
 
  476    -> 
decltype(
from_json(j, std::forward<T>(val)))
 
  478        return from_json(j, std::forward<T>(val));
 
 
 
  484#ifndef JSON_HAS_CPP_17 
  493#ifndef JSON_HAS_CPP_17 
#define WPI_JSON_NAMESPACE_END
Definition abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition abi_macros.h:53
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition exceptions.h:211
#define JSON_HEDLEY_UNLIKELY(expr)
Definition hedley.h:1396
#define JSON_INLINE_VARIABLE
Definition macro_scope.h:147
#define JSON_THROW(exception)
Definition macro_scope.h:171
detail namespace with internal helper functions
Definition input_adapters.h:32
make_integer_sequence< size_t, N > make_index_sequence
Definition ranges.h:148
OutStringType concat(Args &&... args)
Definition string_concat.h:137
@ value
the parser finished reading a JSON value
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition from_json.h:383
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition from_json.h:194
auto get(const wpi::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition iteration_proxy.h:193
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::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition from_json.h:277
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition from_json.h:37
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition from_json.h:51
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition from_json.h:377
Definition from_json.h:472
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition from_json.h:474
Definition identity_tag.h:18
Definition cpp_future.h:66
static constexpr auto value
Definition type_traits.h:420
Definition cpp_future.h:149
Definition cpp_future.h:155
typename std::enable_if< B, T >::type enable_if_t
Definition base.h:297