16#include <nlohmann/json.hpp>
17using json = nlohmann::json;
64template<std::
size_t N>
71 template<
typename Variant>
76 v = value.get<std::variant_alternative_t<N, Variant>>();
93 template<
typename Variant>
98 v = value.get<std::variant_alternative_t<0, Variant>>();
102 throw std::runtime_error(
103 "while converting json to variant: invalid index");
114template<
typename... Args>
115struct adl_serializer<std::variant<Args...>>
122 std::visit([&](
auto&& value) {
123 j[
"index"] = v.index();
124 j[
"value"] = std::forward<decltype(value)>(value);
133 auto const index = j.at(
"index").get<
int>();
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
void from_json(const json &j, ImColor &color)
Converts the provided json object into a color.
void to_json(json &j, const ImColor &color)
Converts the provided color into a json object.
void operator()(int index, const json &value, Variant &v) const
Access operator into the variant.
Definition Json.hpp:94
Variant serialize implementation.
Definition Json.hpp:66
void operator()(int index, const json &value, Variant &v) const
Access operator into the variant.
Definition Json.hpp:72
static void to_json(json &j, const std::variant< Args... > &v)
Write info to a json object.
Definition Json.hpp:120
static void from_json(const json &j, std::variant< Args... > &v)
Read info from a json object.
Definition Json.hpp:131