What are you trying to do? Why do you care to have the null mapping preserved?
Inder
So, here is a design that I can think of:
add a new method in GsonBuilder, enableSerializationOfNulls (feel free
to suggest an alternate name).
Calling this method will serialize all null fields.
This design has the drawback that you can not apply this logic
selectively. Will that be an issue? Would you rather have an
annotation that specified whether to serialize a specific field even
if it is null?
-Eric
GsonBuilder now has an option serializeNulls() that causes all null
values to be serialized.
There is also a new class JsonNull that can be used by custom
serializers to indicate null values.
Can someone look at the change and provide comments on whether this is
good enough?