How use Kotlin enum with Retrofit?

Viewed 17912

How can I parse JSON to model with enum?

Here is my enum class:

enum class VehicleEnumEntity(val value: String) {
   CAR("vehicle"),
   MOTORCYCLE("motorcycle"),
   VAN("van"),
   MOTORHOME("motorhome"),
   OTHER("other")
}

and I need to parse type into an enum

"vehicle": { "data": { "type": "vehicle", "id": "F9dubDYLYN" } }

EDIT

I have tried standard way, just pass my enum to POJO and it always null

2 Answers
Related