Gson ignoring map entries with value=null Gson ignoring map entries with value=null java java

Gson ignoring map entries with value=null


See Gson User Guide - Null Object Support:

The default behaviour that is implemented in Gson is that null object fields are ignored. This allows for a more compact output format; however, the client must define a default value for these fields as the JSON format is converted back into its Java form.

Here's how you would configure a Gson instance to output null:

Gson gson = new GsonBuilder().serializeNulls().create();