|
|
@@ -11,7 +11,7 @@
|
|
|
|
|
|
#include <expect/expect.hpp>
|
|
|
#include <json/json.h>
|
|
|
-#include <magic_enum.hpp>
|
|
|
+#include <magic_enum/magic_enum.hpp>
|
|
|
#include <string_utils/cast.h>
|
|
|
|
|
|
#include <serializer/jsonizer.h>
|
|
|
@@ -40,7 +40,8 @@ Json::Value Jsonizer::to_json(T & value, std::index_sequence<Is...>) const {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
-template <typename T> Json::Value Jsonizer::to_json(std::optional<T> const &opt) const {
|
|
|
+template <typename T>
|
|
|
+Json::Value Jsonizer::to_json(std::optional<T> const & opt) const {
|
|
|
return opt.has_value() ? to_json(*opt) : Json::Value();
|
|
|
}
|
|
|
|
|
|
@@ -48,9 +49,7 @@ template <typename T> Json::Value Jsonizer::to_json(T const & value) const {
|
|
|
if constexpr (detail::has_serial_type_v<T>) {
|
|
|
return to_json(static_cast<typename T::serial_type>(value));
|
|
|
} else if constexpr (std::is_enum_v<T>) {
|
|
|
- constexpr auto type =
|
|
|
- magic_enum::as_flags<magic_enum::detail::is_flags_v<T>>;
|
|
|
- return std::string(magic_enum::enum_name<type>(value));
|
|
|
+ return to_string(value);
|
|
|
} else if constexpr (detail::is_tuple_v<T>) {
|
|
|
return to_json(value, std::make_index_sequence<std::tuple_size_v<T>>());
|
|
|
} else if constexpr (std::is_constructible_v<std::string, T>) {
|
|
|
@@ -97,7 +96,8 @@ void Jsonizer::from_json(T & value, Json::Value const & json,
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
-void Jsonizer::from_json(std::optional<T> &opt, Json::Value const & json) const {
|
|
|
+void Jsonizer::from_json(std::optional<T> & opt,
|
|
|
+ Json::Value const & json) const {
|
|
|
opt = json.isNull() ? std::nullopt : std::optional{from_json<T>(json)};
|
|
|
}
|
|
|
|