diff --git a/include/rfl/parsing/Parser_default.hpp b/include/rfl/parsing/Parser_default.hpp index 268ba979..5bc2bfe2 100644 --- a/include/rfl/parsing/Parser_default.hpp +++ b/include/rfl/parsing/Parser_default.hpp @@ -71,11 +71,15 @@ struct Parser { /// Converts the variable to a JSON type. static auto write(const W& _w, const T& _var) noexcept { if constexpr (supports_attributes && internal::is_attribute_v) { - const auto r = resolve_reflection_type(_var); - return _w.from_basic_type(r, true); + return _w.from_basic_type(resolve_reflection_type(_var), true); } else if constexpr (internal::has_reflection_type_v) { - const auto r = resolve_reflection_type(_var); - return Parser>::write(_w, r); + using ReflectionType = std::decay_t; + if constexpr (internal::has_reflection_method_v) { + return Parser::write(_w, _var.reflection()); + } else { + const auto& [r] = _var; + return Parser::write(_w, r); + } } else if constexpr (std::is_class_v && std::is_aggregate_v) { const auto ptr_named_tuple = internal::to_ptr_named_tuple(_var); using PtrNamedTupleType = std::decay_t;