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)
}
Yupp,您必须使用自己的实现,因为没有内置的Reads [Byte]。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.