I want to serialize nulls for a specific field in GSON. I have looked at the solution provided here as well as several others which fail when setting:
minifyEnabled true
shrinkResources true
I have been trying various (failed attempts) at modifying the answers given in the link, but I have not had any luck.
Given my object looks as follows:
data class EmojiType(
@SerializeNull
var value: String?
)
When I create a post request and pass null, I expect my object to look as follows:
{
"value":null
}
However, as mentioned, when minifyEnabled
and shrinkResources
are set to true
, my object ends up looking like this:
{
"a":null
}
How can I avoid this and retain the field name of value
?