Answers for "json ignore null or empty java"

2

jackson ignore null

public class MyDto {     
	@JsonInclude(Include.NON_NULL)
  	private String stringValue;
  
  	private int intValue;     // standard getters and setters
}
Posted by: Guest on October-28-2020
1

jackson ignore values if empty

// every Value

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ObjectWithoutEmpty {

  	// only not empty Values get included 
    @JsonProperty("propertyOne")
    private String propertyOne;

  	// only not empty Values get included 
    @JsonProperty("propertyTWO")
    private String propertyTWO;

}

// one property


public class ObjectWithoutEmpty {

  	// only non empty Values get included 
  	@JsonInclude(JsonInclude.Include.NON_EMPTY)
    @JsonProperty("propertyOne")
    private String propertyOne;
  
	// empty Values get included 
    @JsonProperty("propertyTWO")
    private String propertyTWO;

}
Posted by: Guest on June-25-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language