I'd like to use hardcoded values in JSON implicit reads, something like:
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 _)
Does anyone know how to do this?
Use Reads.pure
to produce Reads
that yield a constant value.
implicit val locationReads: Reads[Location] = (
Reads.pure("I am a hardcoded value") and
(JsPath \ "lat").read[Double] and
(JsPath \ "long").read[Double]
)(Location.apply _)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With