I have a spring webservice that returns a json response. I\'m using the example given here to create the service: http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-exam
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY) public class Shop { //... }
for jackson 2.0 or later use @JsonInclude(Include.NON_NULL)
@JsonInclude(Include.NON_NULL)
This will remove both empty and null Objects.