I am using Java and Jackson library to parse a JSON file to a Java class. My problem is that I can't set a default value if the value is null or empty. Is it possible to do it? For now, I just write it in the setters section.
For example, I have a JSON file
{"CountryCode": "",
"sourceName": "",
"from": "type1",
"to": "type2"}
And in my Java class I would like to set the value to some Java function if it is null or empty.
For example
public class ExClass{
@JsonProperty("CountryCode")
private String countryCode = "USA";
}
So, if the value is set, then it will be it. If it is not, then it should be USA.