turansky
03/18/2017, 3:27 PMJSON.parse()
?
For example:
// JSON
{
name: “Machine #1”
status: 1 // possible values 1,2,3,4
}
// Data class
data class Data(val name: String, val status: Status)
enum class Status {
NORMAL(1),
DISABLED(2),
....
}
// read code
JSON.parse<Data>(source)
bashor
03/20/2017, 11:33 AMturansky
03/21/2017, 7:18 AMbashor
03/21/2017, 12:48 PMhow external enum class will help meIn your kotlin code it will be typed but at runtime it still will be number
JS realization where static field are numbers required?yes, if you want to use entries in Kotlin code, like
Status.NORMAL
. I’d add it anyway, since it will be safer.