Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using class to determine what fields are serialized with Jackson
 
Similar Threads
Unable to compile class for JSP
Help with calling EJB in jsp page
Question about composite primary key in JPA.
JPA relations become null when flushed
Good Code? Bad Code?