I want to remove null and "" values data from JSON responce output [SOLVED]

This question already has an answer here:

  • Jackson serialization: ignore empty values (or null)

    7 answers

here I am using Annotation on Entity class

import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonInclude;
public class MappingDTO {

    private String mid; 
    private String location;
    private String department;
    private String role;
    private String tenent_id;
    private String cid;
    private ArrayList<CategoryDTO> categoryDTOAL;
    //setters and getters

and using Jar is


My Current output


Expected Output


How to i’m solve it when my this Annotation is failed to solve this

if you want to ignore null or “” value then you can tru @JsonInclude(Include.NON_NULL) or @JsonInclude(Include.NON_EMPTY) begore class.

you can find below sample code:

public static class Test {


you can also use @JsonIgnore on any fix column as per your use case.