bjf*_*her 4 json scala playframework
我想在JSON隐式读取中使用硬编码值,例如:
implicit val locationReads: Reads[Location] = (
"I am a hardcoded value" and // something like that
(JsPath \ "lat").read[Double] and
(JsPath \ "long").read[Double]
)(Location.apply _)
Run Code Online (Sandbox Code Playgroud)
有谁知道如何做到这一点?
使用Reads.pure生产Reads成品率恒定值.
implicit val locationReads: Reads[Location] = (
Reads.pure("I am a hardcoded value") and
(JsPath \ "lat").read[Double] and
(JsPath \ "long").read[Double]
)(Location.apply _)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |