trait Reads[A] extends AnyRef
A Reads
object describes how to decode JSON into a value.
Reads
objects are typically provided as implicit values. When Reads
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 a Reads
and a Writes
then you get a Format.
- Self Type
- Reads[A]
- Annotations
- @implicitNotFound("No Json deserializer found for type ${A}. Try to implement an implicit Reads or Format for this type.")
- Source
- Reads.scala
- Alphabetic
- By Inheritance
- Reads
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def andThen[B](rb: Reads[B])(implicit witness: <:<[A, JsValue]): Reads[B]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[B](error: JsonValidationError)(f: PartialFunction[A, B]): Reads[B]
- def composeWith[B <: JsValue](rb: Reads[B]): Reads[A]
Creates a new
Reads
, which first passes the input JSON torb
, and then it executes thisReads
on the pre-processed JSON (ifrb
has successfully handled the input JSON). - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def filter(error: JsonValidationError)(f: (A) => Boolean): Reads[A]
- def filter(f: (A) => Boolean): Reads[A]
- def filterNot(error: JsonValidationError)(f: (A) => Boolean): Reads[A]
- def filterNot(f: (A) => Boolean): Reads[A]
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B](f: (A) => Reads[B]): Reads[B]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) => B): Reads[B]
Create a new
Reads
which maps the value produced by thisReads
.Create a new
Reads
which maps the value produced by thisReads
.- B
The type of the value produced by the new
Reads
.- f
the function applied on the result of the current instance, if successful
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def orElse(v: Reads[A]): Reads[A]
Creates a new
Reads
, based on this one, which first executes thisReads
' logic then, if thisReads
resulted in aJsError
, runs the secondReads
on the JsValue.Creates a new
Reads
, based on this one, which first executes thisReads
' logic then, if thisReads
resulted in aJsError
, runs the secondReads
on the JsValue.- v
the
Reads
to run if this one gets aJsError
- returns
A new
Reads
with the updated behavior.
- def preprocess(f: PartialFunction[JsValue, JsValue]): Reads[A]
Creates a new
Reads
, which first transforms the input JSON using the giventranformer
, and then it executes thisReads
on the pre-processed JSON. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def widen[B >: A]: Reads[B]
Widen this
Reads
.Widen this
Reads
.import play.api.libs.json.Reads sealed trait Animal case class Dog(name: String) extends Animal case class Cat(name: String) extends Animal def simple(r: Reads[Dog]): Reads[Animal] = r.widen[Animal]
Deprecated Value Members
- def compose[B <: JsValue](rb: Reads[B]): Reads[A]
- Annotations
- @deprecated
- Deprecated
(Since version 2.7.0) Use composeWith