This trait provides an instance of Writes
for an enumeration.
This trait provides an instance of Reads
for an enumeration.
This trait provides an instance of Reads
for an enumeration. It works
by extending the companion object of the enumeration class.
@enum class Color { Red Blue Yellow } object Color extends FromJson[Color]
If you need your Reads
instance to be case-insensitive you can override
the caseSensitive
member like so:
@enum class Color { Red Blue Yellow } object Color extends FromJson[Color] { override val caseSensitive = false }
This trait provides an instance of Reads
for an enumeration.
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]
Allows you to read JSON numbers as Color like so:
JsNumber(0).validate[Color] // JsResult(Red)
This trait provides an instance of Format
for an enumeration.
This trait provides an instance of Format
for an enumeration. It works
by extending the companion object of the enumeration class.
@enum class Color { Red Blue Yellow } object Color extends JsonConverters[Color]
If you need your Format
instance to be case-insensitive you can override
the caseSensitive
member like so:
@enum class Color { Red Blue Yellow } object Color extends JsonConverters[Color] { override val caseSensitive = false }
This trait provides an instance of
Writes
for an enumeration. It works by extending the companion object of the enumeration class.