In this post under Gson, I will show how to change the naming convention of field names when serialized to JSON format. I will show how to change the naming convention from out of the box provided standard naming conventions. Gson out of the box provides the below naming conventions as part of the enum…… Continue reading FieldNamingPolicy Example
Month: September 2019
Configuring Gson to serialize objects with fields having null value
Whenever we serialize a java object to JSON using Gson framework, by default fields with null values are ignored. As shown in the below code Main code import com.google.gson.Gson; public class GsonDemo7 { public static void main(String[] args) { Student student = new Student(); student.setId(1); student.setName(“name1”); student.setRollnum(100); student.setDate(null); Gson gson = new Gson(); String result…… Continue reading Configuring Gson to serialize objects with fields having null value