Discussion:
[Springframework-rcp-dev] overriding jackson default json serializing
Amr Shahin
2014-06-19 10:26:32 UTC
Permalink
Hello,
I'm running into an interesting case with spring and jackson.
So i'm building a REST API with spring, and i'm trying to limit the
response of the controller to only a specific set of fields defined in the
URL (something like f=id that will return only the ID instead of the whole
object).

I wrote a custom serializer for my domain classes but it's being called
multiple times for some reason.

Also, it seems that a different class is being called for different class
members, the reason why i think so is that i'm getting this exception
"Current context not an ARRAY but OBJECT" even though i'm not mentioning
any arrays/Iterables in my class.

My question is, is this the best way to limit the response size dynamically
(i'm aware of the jsonignoreproperties annotation but it's not as dynamic
as i want). And if it is what is the best strategy to define my own
serializer that handles all those cases.

Thanks.

Loading...