如何解析JSON以使用enum建模?
这是我的枚举类:
enum class VehicleEnumEntity(val value: String) {
CAR("vehicle"),
MOTORCYCLE("motorcycle"),
VAN("van"),
MOTORHOME("motorhome"),
OTHER("other")
}
我需要把type
解析成一个枚举
"vehicle": { "data": { "type": "vehicle", "id": "F9dubDYLYN" } }
EDIT
我try 了标准方法,只需将枚举传递给POJO,它总是空的