GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes Using class to determine what fields are serialized with Jackson Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Using class to determine what fields are serialized with Jackson" Watch "Using class to determine what fields are serialized with Jackson" New topic
Author

Using class to determine what fields are serialized with Jackson

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
What is the fastest way to use a class to determine which fields are serialized by jackson. I have objects defined in my gwt app that I would like to use for this. This seems like it would be a somewhat common use case.

I am familiar with JsonViews, but this would require me to annotate fields in the object. Effectively duplicating the 'which fields are included' logic (in the BookDetail object and in the Book entity)

I have looked into JsonFilter, but this seems like each entity (Book) could only have one filter and I haven't figured out how to use a class definition to define the filter.

The ideal solution would look something like this. Is this possible out of the box, or am I going to have to 'roll my own' bean serializer?



http://www.goodercode.com
SCJP 1.4
 
GeeCON Prague 2014
 
subject: Using class to determine what fields are serialized with Jackson