moshi custom qualifier annotation to serialise null on one property only

前端 未结 2 1731
轻奢々
轻奢々 2021-01-18 16:24

I\'d like to serialise null for only one property in my JSON body that is going on a PUT. I don\'t want to serialize null for any other types in the object. Model class is l

2条回答
  •  时光取名叫无心
    2021-01-18 16:40

    Try approach from my gist:

    https://gist.github.com/OleksandrKucherenko/ffb2126d37778b88fca3774f1666ce66

    In my case I convert NULL from JSON into default double/integer value. You can easily modify the approach and make it work for your specific case.

    p.s. its JAVA, convert it to Kotlin first.

提交回复
热议问题