trait Format[A] extends Writes[A] with Reads[A]
Json formatter: write an implicit to define both a serializer and a deserializer for any type.
- Annotations
- @implicitNotFound()
- Source
- Format.scala
- Alphabetic
- By Inheritance
- Format
- Reads
- Writes
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
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]
- Definition Classes
- Reads
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bimap[B](readsMap: (A) => B, writesContramap: (B) => A): Format[B]
Maps reads and writes operations between the types
A
andB
, using the given functions.Maps reads and writes operations between the types
A
andB
, using the given functions.- readsMap
the function applied to the read
A
value
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def collect[B](error: JsonValidationError)(f: PartialFunction[A, B]): Reads[B]
- Definition Classes
- Reads
- 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).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).- Definition Classes
- Reads
- def contramap[B](f: (B) => A): Writes[B]
Returns a new instance that first converts a
B
value to aA
one, before converting thisA
value into a JsValue. - 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]
- Definition Classes
- Reads
- def filter(f: (A) => Boolean): Reads[A]
- Definition Classes
- Reads
- def filterNot(error: JsonValidationError)(f: (A) => Boolean): Reads[A]
- Definition Classes
- Reads
- def filterNot(f: (A) => Boolean): Reads[A]
- Definition Classes
- Reads
- def flatMap[B](f: (A) => Reads[B]): Reads[B]
- Definition Classes
- Reads
- def flatMapResult[B](f: (A) => JsResult[B]): Reads[B]
Creates a new
Reads
, which transforms the successful result from the current instance using the given function.Creates a new
Reads
, which transforms the successful result from the current instance using the given function.- f
the function applied on the successful
A
valuefinal class Foo private(val code: String) extends AnyVal val A = new Foo("A") val B = new Foo("B") import play.api.libs.json.Reads val r: Reads[Foo] = implicitly[Reads[String]].flatMapResult { case "A" => JsSuccess(A) case "B" => JsSuccess(B) case _ => JsError("error.expected.foo") }
- Definition Classes
- Reads
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @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
- Definition Classes
- Reads
- def narrow[B <: A]: Writes[B]
Narrows to any
B
super-type ofA
.Narrows to any
B
super-type ofA
.- Definition Classes
- Writes
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @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. - 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.Creates a new
Reads
, which first transforms the input JSON using the giventranformer
, and then it executes thisReads
on the pre-processed JSON.- Definition Classes
- Reads
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def transform(transformer: Writes[JsValue]): Writes[A]
Transforms the resulting JsValue using a
Writes[JsValue]
. - def transform(transformer: (JsValue) => JsValue): Writes[A]
Transforms the resulting JsValue using transformer function.
- 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()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- 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]
- Definition Classes
- Reads
Deprecated Value Members
- def compose[B <: JsValue](rb: Reads[B]): Reads[A]
- Definition Classes
- Reads
- Annotations
- @deprecated
- Deprecated
(Since version 2.7.0) Use composeWith
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)