Skip to content

Commit b7bec6a

Browse files
committed
fable: Fix regression with FromJson not finding (de-)serializer
1 parent 7872c16 commit b7bec6a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

fable/include/fable/schema/json.hpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,20 @@ class FromJson : public Base<FromJson<T>> {
7777
void reset_ptr() override { ptr_ = nullptr; }
7878

7979
[[nodiscard]] Json serialize(const Type& x) const {
80-
Json j;
81-
serialize_into(j, x);
82-
return j;
80+
return Json(x);
8381
}
8482

8583
void serialize_into(Json& j, const Type& x) const {
86-
to_json(j, x);
84+
::nlohmann::adl_serializer<Type>::to_json(j, x);
8785
}
8886

8987
template<typename = std::enable_if<std::is_default_constructible_v<Type>>>
9088
[[nodiscard]] Type deserialize(const Conf& c) const {
91-
Type x;
92-
deserialize_into(c, x);
93-
return x;
89+
return c->get<Type>();
9490
}
9591

9692
void deserialize_into(const Conf& c, Type& x) const {
97-
from_json(*c, x);
93+
c->get_to(x);
9894
}
9995

10096
private:

0 commit comments

Comments
 (0)