0

I have a List of JSON Object where I want to take only those JSON object whose all the values are not null. If Any of the JSON Object field is null , I want to ignore the Complete JSON Object.

[
 {
  "id":"1",
  "address": "abc",
  "name": "edf"
 },
 {
  "id": "2",
  "address": null,
  "name" : "cnh"
 },
 {
  .
  .
  .
 }
]

In this example I want to ignore the Second JSON Object of id=2 completely.

I have tried @JsonInclude(Include.NON_NULL) at fields level and class level but this only ignores the fields and keeps the Object.

CodeGeek
  • 31
  • 1
  • 7
  • Try to check this answer: https://stackoverflow.com/questions/11449211/how-to-prevent-null-values-inside-a-map-and-null-fields-inside-a-bean-from-getti – Aldas Butkus Mar 03 '21 at 07:04
  • Not related to my question. – CodeGeek Mar 03 '21 at 07:15
  • @CodeGeek Please share your classes & the function which does this unexpected behaviour. – papaya Mar 03 '21 at 07:56
  • Its just a requirement , I have not written any code. The reason is , I am getting almost 800 JSON Objects in this list. Out of 800 only 10 objects have address as not null, so I want to take only those Json object which are having address. – CodeGeek Mar 03 '21 at 08:18

0 Answers0