|
|
@@ -105,7 +105,9 @@ void Jsonizer::from_json(T & value, Json::Value const & json) const {
|
|
|
if constexpr (detail::has_serial_type_v<T>) {
|
|
|
value = T(from_json<typename T::serial_type>(json));
|
|
|
} else if constexpr (std::is_enum_v<T>) {
|
|
|
- if (!string_utils::cast(value, json.asString())) {
|
|
|
+ if (json.isInt()) {
|
|
|
+ value = *magic_enum::enum_cast<T>(json.asInt());
|
|
|
+ } else if (!string_utils::cast(value, json.asString())) {
|
|
|
throw std::invalid_argument("Cannot cast to enum: " + json.asString());
|
|
|
}
|
|
|
} else if constexpr (std::is_same_v<std::string, T>) {
|