If you mark the getter method with the @JsonIgnore annotation it should not be serialized. Here is an example:
public class JacksonIgnore {
public static class Release {
public final String version;
public Release(String version) {
this.version = version;
}
}
public static class Project {
public final String name;
public Project(String name) {
this.name = name;
}
@JsonIgnore
public List<Release> getAllReleases() {
return Arrays.asList(new Release("r1"), new Release("r2"));
}
}
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(new Project("test")));
}
}
Output:
{
"name" : "test"
}