@JsonInclude (JsonInclude.Include.NON_NULL) does not work in the list

@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
Public class Event{
private int Id;
private String name;
}


    @JsonInclude(JsonInclude.Include.NON_NULL)
    @Data
    @AllArgsConstructor
    Public class EventResponse{
        private List<Event> eventList;

  }

In response, I am sending a list of events. I am using spring-boot. If Cassandra has no data with an identifier, it returns null. The answer I get is

"eventList": [
    {
      "event": {
        "id": 1234,
        "name": "Halus"
      }
    },
    {}
]

But I expect

"eventList": [
    {
      "event": {
        "id": 1234,
        "name": "Halus"
      }
    }
]
+4
source share

Source: https://habr.com/ru/post/1673133/


All Articles