Nullsafe adapter not writing null values
Closed this issue · 2 comments
Meisolsson commented
When unsetting a value with a request the API I'm talking to requires the value which is being unset to be null
. I have a nullsafe adapter factory and the value is nullable but when the values are being written the null value is skipped. I'm guessing this is expected behaviour but I'd like to know if I can skip this for certain values (or all).
ZacSweers commented
if I'm reading this correctly, this is normal behavior and you need to enable serializeNulls()
in the writer that's passed in
val writer = JsonWriter.of(...)
writer.serializeNulls()
moshi.adapter(...)
.toJson(writer, object)
rharter commented
I'm closing this as it's not an auto-value-moshi issue. If you find an issue relating to this with AVM feel free to reopen.