Pregunta

How can I handle Byte in Json Scala API, for example parsing:

json.as[Byte]

Do I have to write own Reads?

implicit val ByteRead = new Reads[Byte] {
   override def reads(json: JsValue): JsResult[Byte] = JsSuccess(json.as[Int].toByte)
}
¿Fue útil?

Solución

Yupp, you'd have to use your own implementation as there is no built in Reads[Byte].

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top