Play Framework: How to serialize/deserialize an enumeration to/from JSON

前端 未结 5 1173
有刺的猬
有刺的猬 2020-12-29 20:43

Given the following enumeration...

object MyEnum extends Enumeration {

  type MyEnum = Value

  val Val1 = Value(\"val1\")
  val Val2 = Value(\"val2\")
  va         


        
5条回答
  •  隐瞒了意图╮
    2020-12-29 21:11

    I have put together more generic and re-usable EnumerationReads, EnumerationWrites and EnumerationFormat classes and have posted them on my github page:

    EnumerationCombinators.scala

提交回复
热议问题