You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a @Controller containing a method returning an abstract object (Foo). Another method returns an instance Bar (Bar extends Foo), and this is returned from the request-handler.
The bug is that the fields defined on Bar but not on Foo is dropped during serialization to JSON.
If I return List<Bar> instead of just Bar, it works (all fields are correctly serialized).
A workaround for us now is to return the correct type from the request-handler, manually casting it from Foo to Bar.
Manually calling new ObjectMapper().writeValueAsString on the object in the controller produces the correct JSON, but whatever Spring does to it does not.
Using Jackson 2.6.1
EDIT: Using Spring 4.2.1 fixes the problem. Sorry about the noise!
Simen Bekkhus opened SPR-13429 and commented
Not really a good title...
We have a
@Controller
containing a method returning an abstract object (Foo). Another method returns an instance Bar (Bar extends Foo), and this is returned from the request-handler.The bug is that the fields defined on Bar but not on Foo is dropped during serialization to JSON.
If I return List<Bar> instead of just Bar, it works (all fields are correctly serialized).
A workaround for us now is to return the correct type from the request-handler, manually casting it from Foo to Bar.
Manually calling new ObjectMapper().writeValueAsString on the object in the controller produces the correct JSON, but whatever Spring does to it does not.
Using Jackson 2.6.1
EDIT: Using Spring 4.2.1 fixes the problem. Sorry about the noise!
Affects: 4.2 GA
Issue Links:
The text was updated successfully, but these errors were encountered: