Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Ignore json response fields dynamically in RESTEasy/jackson

 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have developed Restful service using RESTEasy framework and Jackson for json response.

I am using data layer to return plain POJO class object(setters and getters), which gets returned from REST service as JSON.

My question is:
How to modify/filter response (without modifying POJO), to send back only few fields based on condition and not all fields of the POJO.

Thanks in advance,
Nikesh
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe use another POJO class that is created from the one that has too many fields, and copy those fields to it that you want to transfer.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick response.

Actually I am looking for a solution to avoid creating more POJOs if dynamically fields can be excluded.



 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for "jackson custom serialization"; you'll have to do some extra effort in that case.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks Ulf Dittmer,

Following link helped in achieving the desired result.

Exclude JSON Fields dynamically

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!