java - Default null Integer field to null instead of 0 using Jackson -


i'm trying default missing integer value null when deserializing json java using jackson library version 2.8.8.

for example, following json missing age attribute:

{   "name": "me" } 

and java class

public class person {   private integer age;   private string name;    public integer getage(){     return this.age;   }    public void setage(integer age){     this.age = age;   }    //omitting getters , setters of name verbosity sake } 

what i'm ending java object age 0 , name "me". i'd have age null instead of 0.

i'm using code conversion:

objectmapper mapper = new objectmapper(); mapper.readvalue(json, person.class); 

according github issue on fasterxml, framework should defaulting value null instead of 0 since i'm using wrapper class (integer). don't have ability modify pojo being used because being generated framework i'm using, when inspect generated setter or debug , @ setter within beandeserializerfactory.class used jackson showing setter java.lang.integer , not primitive int.

why jackson defaulting integer 0 instead of null , how can configure jackson default missing integers null?


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -