diff options
Diffstat (limited to 'lib/converters.h')
-rw-r--r-- | lib/converters.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/converters.h b/lib/converters.h index 5e3becb8..49cb1ed9 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -16,6 +16,7 @@ #include <type_traits> #include <vector> +#include <variant> class QVariant; @@ -224,6 +225,13 @@ struct QUOTIENT_API JsonConverter<QVariant> { static QVariant load(const QJsonValue& jv); }; +template <typename... Ts> +inline QJsonValue toJson(const std::variant<Ts...>& v) +{ + return std::visit( + [](const auto& value) { return QJsonValue { toJson(value) }; }, v); +} + template <typename T> struct JsonConverter<Omittable<T>> { static QJsonValue dump(const Omittable<T>& from) |