Jackson JSON Marshall ignore getter
JsonJacksonJson Problem Overview
Im using Jackson to convert a POJO into a JSON to store in the DB. However I have a getter that I want to ignore. I have see a lot of info relating to @JsonIgnoreProperties but I can't seem to make any progress with it. I basically want the equivalent of @Transient.
Basic usecase (I want to ignore the InternationalNumber):
public class PhoneNumber {
private String country;
private String number;
public PhoneNumber() {}
public String getCountry() {
return country;
}
public String getLocalNumber() {
return localNumber;
}
public String getInternationalNumber() {
String result = "Not Available";
if (country != null && localNumber != null) {
result = new PhoneNumberHandler().internationalFormat(
localNumber, WorldCountries.countryToIso2Code(country));
}
return result;
}
}
Json Solutions
Solution 1 - Json
That would be @JsonIgnore
on getter method.