WPILibC++ 2025.0.0-alpha-1-24-g6478ba6
adl_serializer.h
Go to the documentation of this file.
1// __ _____ _____ _____
2// __| | __| | | | JSON for Modern C++
3// | | |__ | | | | | | version 3.11.3
4// |_____|_____|_____|_|___| https://github.com/nlohmann/json
5//
6// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
7// SPDX-License-Identifier: MIT
8
9#pragma once
10
11#include <utility>
12
17
19
20/// @sa https://json.nlohmann.me/api/adl_serializer/
21template<typename ValueType, typename>
23{
24 /// @brief convert a JSON value to any value type
25 /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
26 template<typename BasicJsonType, typename TargetType = ValueType>
27 static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
28 noexcept(::wpi::from_json(std::forward<BasicJsonType>(j), val)))
29 -> decltype(::wpi::from_json(std::forward<BasicJsonType>(j), val), void())
30 {
31 ::wpi::from_json(std::forward<BasicJsonType>(j), val);
32 }
33
34 /// @brief convert a JSON value to any value type
35 /// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
36 template<typename BasicJsonType, typename TargetType = ValueType>
37 static auto from_json(BasicJsonType && j) noexcept(
38 noexcept(::wpi::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
39 -> decltype(::wpi::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
40 {
41 return ::wpi::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
42 }
43
44 /// @brief convert any value type to a JSON value
45 /// @sa https://json.nlohmann.me/api/adl_serializer/to_json/
46 template<typename BasicJsonType, typename TargetType = ValueType>
47 static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
48 noexcept(::wpi::to_json(j, std::forward<TargetType>(val))))
49 -> decltype(::wpi::to_json(j, std::forward<TargetType>(val)), void())
50 {
51 ::wpi::to_json(j, std::forward<TargetType>(val));
52 }
53};
54
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
WPILIB_DLLEXPORT void from_json(const wpi::json &json, AprilTagFieldLayout &layout)
WPILIB_DLLEXPORT void to_json(wpi::json &json, const AprilTagFieldLayout &layout)
namespace for Niels Lohmann
Definition: adl_serializer.h:23
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::wpi::to_json(j, std::forward< TargetType >(val)))) -> decltype(::wpi::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: adl_serializer.h:47
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::wpi::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::wpi::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: adl_serializer.h:27
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::wpi::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::wpi::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: adl_serializer.h:37
Definition: identity_tag.h:18