2022-07-20 12:38:07 +02:00
|
|
|
// __ _____ _____ _____
|
|
|
|
// __| | __| | | | JSON for Modern C++
|
2022-08-12 15:04:06 +02:00
|
|
|
// | | |__ | | | | | | version 3.11.2
|
2022-07-20 12:38:07 +02:00
|
|
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
|
|
|
//
|
|
|
|
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2018-01-10 10:18:31 +01:00
|
|
|
#pragma once
|
2017-08-14 18:22:49 +02:00
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
2022-07-30 21:59:13 +02:00
|
|
|
#include <nlohmann/detail/abi_macros.hpp>
|
2018-01-29 11:21:11 +01:00
|
|
|
#include <nlohmann/detail/conversions/from_json.hpp>
|
|
|
|
#include <nlohmann/detail/conversions/to_json.hpp>
|
2021-01-10 19:23:32 +01:00
|
|
|
#include <nlohmann/detail/meta/identity_tag.hpp>
|
2017-08-14 18:22:49 +02:00
|
|
|
|
2022-07-30 21:59:13 +02:00
|
|
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
2018-10-28 09:15:41 +01:00
|
|
|
|
2021-12-29 13:41:01 +01:00
|
|
|
/// @sa https://json.nlohmann.me/api/adl_serializer/
|
2021-01-09 00:08:27 +01:00
|
|
|
template<typename ValueType, typename>
|
2017-08-14 18:22:49 +02:00
|
|
|
struct adl_serializer
|
|
|
|
{
|
2021-12-29 13:41:01 +01:00
|
|
|
/// @brief convert a JSON value to any value type
|
|
|
|
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
|
2021-01-09 17:45:56 +01:00
|
|
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
|
|
|
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
|
2018-10-28 09:15:41 +01:00
|
|
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
|
|
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
2017-08-14 18:22:49 +02:00
|
|
|
{
|
|
|
|
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
|
|
|
|
}
|
|
|
|
|
2021-12-29 13:41:01 +01:00
|
|
|
/// @brief convert a JSON value to any value type
|
|
|
|
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
|
2021-01-09 17:45:56 +01:00
|
|
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
2021-01-09 00:08:27 +01:00
|
|
|
static auto from_json(BasicJsonType && j) noexcept(
|
2021-01-10 19:23:32 +01:00
|
|
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
|
|
|
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
|
2021-01-09 00:08:27 +01:00
|
|
|
{
|
2021-01-10 19:23:32 +01:00
|
|
|
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
|
2021-01-09 00:08:27 +01:00
|
|
|
}
|
|
|
|
|
2021-12-29 13:41:01 +01:00
|
|
|
/// @brief convert any value type to a JSON value
|
|
|
|
/// @sa https://json.nlohmann.me/api/adl_serializer/to_json/
|
2021-01-09 17:45:56 +01:00
|
|
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
|
|
|
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
|
|
|
|
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
|
|
|
|
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
|
2017-08-14 18:22:49 +02:00
|
|
|
{
|
2021-01-09 17:45:56 +01:00
|
|
|
::nlohmann::to_json(j, std::forward<TargetType>(val));
|
2017-08-14 18:22:49 +02:00
|
|
|
}
|
|
|
|
};
|
2022-07-30 21:59:13 +02:00
|
|
|
|
|
|
|
NLOHMANN_JSON_NAMESPACE_END
|