enumsmoshi

How to fallback on a enum if values don't match in Moshi


I have an enum class and would like it to fallback to a specific enum value if values don't match any of them. I found a Moshi issue that talks about using EnumJsonAdapter but I don't see any public class for me to use.

I'm using Moshi 1.8.0

Any ideas on how to achieve this or is writing a custom JSON adapter the only way to go?


Solution

  • There is an adapters artifact for extra adapters like EnumJsonAdapter.

    https://github.com/square/moshi/tree/master/moshi-adapters#download