Http://www.cnblogs.com/yangy608/p/3936848.html
**********************************************************
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);
Note: The Map list does not work for VO only
For example
objectmapper mapper = new Objectmapper (); Mapper.setserializationinclusion (Include.non_null); Map map = new HashMap (); Map.put ( "a" , null "B", "B" ); String ret_val = mapper.writevalueasstring (map); System.err.println (Ret_val); Map m = Mapper.readvalue (ret_val, Map. Class "a") + "|" + M.get ("B" "B": "B", "a": null } null |b
New VO (); Vo.seta (null); Vo.setb ( "B"); == Mapper.readvalue (Ret_val1, VO.class+ "|" + V.GETB ());<br> output {"B": "B" }|b
Jackson entity to JSON null or NULL to not participate in serialization