I am trying to create a Json object using Jackson library 1.5 but getting objects who have Null values also.
How can I get rid of the Null values?
Below is the code I am using.
package com.test;
public class Sample {
public String name;
public String surname;
public Sample(String name, String surname) {
this.name = name;
this.surname = surname;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
}
public static void main(String[] args){
Sample sample = new Sample("Sam", null);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false);
System.out.println(mapper.writeValueAsString(restRetrieveQuoteResponse));
}
}
The issue here is, in mapper.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false);
WRITE_NULL_PROPERTIES is deprecated.
I have tried to find the alternative for this but could not find. Most of the solutions which are available are with Jackson 2.2. Can someone help me solving this for 1.5?