This trait provides an instance of Reads for an enumeration. Unlike
FromJson, the Reads instance created by this trait operates on
JsNumber using the Int representation of the enumeration. It works
by extending the companion object of the enumeration class.
@enum class Color {
Red
Blue
Yellow
}
object Color extends FromJsonNumeric[Color]
This trait provides an instance of
Reads
for an enumeration. UnlikeFromJson
, theReads
instance created by this trait operates onJsNumber
using theInt
representation of the enumeration. It works by extending the companion object of the enumeration class.Allows you to read JSON numbers as Color like so: