https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Jonathan Olsson

03/25/2021, 11:45 AM
What is the best approach in kotlinx.serialization to encode parameterised values, ie:
Copy code
enum class Status(val value: Int) {
  Ok(0),
  NotOk(1),
  SomeOtherStatus(2)
}
For example, if the incoming JSON has
1
, I want it to be decoded into
Status.NotOk
k

kqr

03/25/2021, 12:00 PM
try #serialization
Although the default will serialize/deserialize enums as names
j

Jonathan Olsson

03/25/2021, 12:39 PM
Thanks! 🙏 Will try it out.
2 Views