Skip to content

Commit

Permalink
Add what I can for value enum serialiser generators
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydmeta committed Mar 14, 2017
1 parent 08ea449 commit a904ff0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions enumeratum-json4s/src/main/scala/enumeratum/values/Json4s.scala
Expand Up @@ -3,6 +3,28 @@ package enumeratum.values
import org.json4s.CustomSerializer
import org.json4s.JsonAST.{JInt, JLong, JString}

/**
* Holds overloaded Json4s CustomSerializer generators for various Enumeratum ValueEnums
*
* {{{
* scala> import enumeratum.values._
* scala> import org.json4s._
* scala> import org.json4s.native.Serialization
*
* scala> sealed abstract class ShirtSize(val value:Int) extends IntEnumEntry
* scala> case object ShirtSize extends IntEnum[ShirtSize] {
* | case object Small extends ShirtSize(1)
* | case object Medium extends ShirtSize(2)
* | case object Large extends ShirtSize(3)
* | val values = findValues
* | }
*
* scala> implicit val formats = Serialization.formats(NoTypeHints) + Json4s.serializer(ShirtSize)
*
* scala> Serialization.write(ShirtSize.values)
* res0: String = [1,2,3]
* }}}
*/
@SuppressWarnings(Array("org.wartremover.warts.Any"))
object Json4s {

Expand Down

0 comments on commit a904ff0

Please sign in to comment.