Now first off, I've read some other answers on this site and others about jackson serialisation but they all provide methods for ignoring
private ObjectWriter mapper = new ObjectMapper().writer();
private myClass data = new myClass(); //class contains a string and int variable
data.setNumber(someInt); //set values
String Json = mapper.writeValueAsString(data);
Using the Jackson JsonInclude annotation:
works around the problem where unassigned primitive types always assumes a default value; in this case, unassigned
0 and are subsequently ignored.