I'm using jersey to serialize responses in a web service. I don't want the service to return null values, so i use the corresponding annotation, like this:
@JsonInclude(Include.NON_NULL)
class City{
String name;
Stat stats;
}
And Stat class looks like this:
class Stat{
int population;
int femalePopulation;
int malePopulation;
}
I don't want properties from Stat to be shown if they are null. But for some reason I keep getting those. I've tried using @JsonInclude(Include.NON_NULL) in Stat class, but it doesn't work :(
Any help will be appreciated.
EDIT:
Sorry, my example wasn't the best one. I know primitives types have default values. I've tried adding the annotation in Stat class, but it's not woking for me :/
class Stat{
Integer population;
Integer femalePopulation;
Integer malePopulation;
}