Creates a new Reads
, which first passes the input JSON to rb
,
and then it executes this Reads
on the pre-processed JSON
(if rb
has successfully handled the input JSON).
Create a new Reads
which maps the value produced by this Reads
.
Create a new Reads
which maps the value produced by this Reads
.
The type of the value produced by the new Reads
.
the function applied on the result of the current instance, if successful
Creates a new Reads
, based on this one, which first executes this
Reads
' logic then, if this Reads
resulted in a JsError
, runs
the second Reads
on the JsValue.
Creates a new Reads
, based on this one, which first executes this
Reads
' logic then, if this Reads
resulted in a JsError
, runs
the second Reads
on the JsValue.
the Reads
to run if this one gets a JsError
A new Reads
with the updated behavior.
Creates a new Reads
, which first transforms the input JSON
using the given tranformer
, and then it executes this Reads
on the pre-processed JSON.
Widen this Reads
.
Widen this Reads
.
import play.api.libs.json.Reads def simple(r: Reads[Dog]): Reads[Animal] = r.widen[Animal] def combine(dog: Reads[Dog], cat: Reads[Cat]): Reads[Animal] = dog.orElse(cat).orElse(Reads.failed[Animal]("Unsupported Animal"))
(Since version 2.7.0) Use composeWith
A
Reads
object describes how to decode JSON into a value.Reads
objects are typically provided as implicit values. WhenReads
implicit values are in scope, a program is able to deserialize JSON into values of the right type.The inverse of a
Reads
object is a Writes object, which describes how to encode a value into JSON. If you combine aReads
and aWrites
then you get a Format.