Enum Json Adapter
A JsonAdapter for enums that allows having a fallback enum value when a deserialized string does not match any enum value. To use, add this as an adapter for your enum type on your Moshi.Builder:
{@code * Moshi moshi = new Moshi.Builder() * .add(CurrencyCode.class, EnumJsonAdapter.create(CurrencyCode.class) * .withUnknownFallback(CurrencyCode.USD)) * .build(); * }
Functions
failOnUnknown
Link copied to clipboard
fromJsonValue
Link copied to clipboard
serializeNulls
Link copied to clipboard
toJsonValue
Link copied to clipboard
withUnknownFallback
Link copied to clipboard
open fun withUnknownFallback(@Nullable() fallbackValue: T): EnumJsonAdapter<T>
Content copied to clipboard