• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How to make POJO attribute optional for JSON response on certain condition ?

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

I want to make POJO attribute optional for JSON response on certain condition.

Like below is my POJO for example.


Here in response of this POJO class, we get both the attributes whether values are available or not.
But i want that on certain condition, Attribute 'b' should pass and on false condition it should not pass in response.

I think we can set conditional setter for it but don't know how to set it.

Can you please help me on this ?
 
Saloon Keeper
Posts: 11471
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give us a concrete example.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!