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
When used with Jersey's JacksonFeature, JSON returned will only contain attribute A and not attribute B because static serialisation of the root type is forced and there is no way I can override that. If, however, I wrap the collection with some other non-generic type, then static serialisation will not be forced and I will get both attribute "a" and "b" in the JSON produced by this GET.
This is a tricky problem, if I recall correctly, and I am not quite sure what to do with it.
My general advice at this point is to never use a generic type as root value, because of multiple related issues, with or without JAX-RS/JAX-WS. Beyond issue of static/dynamic content types, there is also the problem with polymorphism (for general case, hopefully not in your case).
But first things first: just to make sure, can this be reproduced with 2.6.1 as well?
This is how we worked around it, having something else wrapping the collection as a root value was better design anyway. To be honest, our problem is solved and I do not think I can spend much more time on this. I just thought it's something you may want to fix, but since it's complicated maybe documentation could explicitly warn users from doing it.
@ylexus I appreciate your reporting this, and I agree that at very least it is worth commenting. It has been an on-going challenge as well, trying to balance sometimes conflicting needs. And finally, it is valuable to have issues filed for when others hit the same problem -- at least they can read more about problem itself, work-arounds and so forth.
I will keep this open for now, since there are some ideas for 2.7 that could help here.
Example:
When used with Jersey's JacksonFeature, JSON returned will only contain attribute A and not attribute B because static serialisation of the root type is forced and there is no way I can override that. If, however, I wrap the collection with some other non-generic type, then static serialisation will not be forced and I will get both attribute "a" and "b" in the JSON produced by this GET.
jackson-jaxrs-base version used is 2.5.4.
Issue originally reported against Jersey but they are inclined to blame jackson: https://java.net/jira/browse/JERSEY-2939.
The text was updated successfully, but these errors were encountered: