1. On-Entity
@JsonInclude (Include.non_null)
Place the tag on the property, if the property is null, does not participate in serialization
If placed on top of a class, it works for all properties of the class
Include.Include.ALWAYS Default
The Include.non_default property is not serialized as the default value
Include.non_empty property is empty ("") or null is not serialized
Include.non_null property is NULL not serialized
2. On the Code
Objectmapper mapper = new Objectmapper ();
Mapper.setserializationinclusion (Include.non_null);
The Mapper object is set by this method, and all serialized objects are serialized according to the rules.
Include.Include.ALWAYS Default
The Include.non_default property is not serialized as the default value
Include.non_empty property is empty ("") or null is not serialized
Include.non_null property is NULL not serialized
User user = new User (1, "", null);
String Outjson = mapper.writevalueasstring (user);
System.out.println (Outjson);
Jackson entity to JSON null or NULL to not participate in serialization