Default deserializer type classes.
Attributes
- Companion
- trait
- Graph
-
- Supertypes
-
trait GeneratedReadstrait DefaultReadstrait LowPriorityDefaultReadstrait EnvReadstrait PathReadstrait ConstraintReadsclass Objecttrait Matchableclass AnyShow all
- Self type
-
Reads.type
Members list
Type members
Classlikes
Attributes
- Supertypes
- Self type
-
JsArrayMonoid.type
Attributes
- Supertypes
- Self type
-
JsObjectMonoid.type
Inherited classlikes
Deserializer for BigInt
Deserializer for BigInteger
Deserializer for Boolean types.
Deserializer for Byte types.
Deserializer for Double types.
Deserializer for Float types.
Deserializer for Int types.
Deserializer for JsArray.
Deserializer for JsBoolean.
Deserializer for JsNumber.
Deserializer for JsObject.
Deserializer for JsString.
Deserializer for JsValue.
Deserializer for Long types.
Deserializer for Short types.
Deserializer for String types.
Parsing companion
Parsing companion
Attributes
- Inherited from:
- EnvReads
- Supertypes
-
class Objecttrait Matchableclass Any
Typeclass to implement way of parsing string as Java8 temporal types.
Typeclass to implement way of parsing string as Java8 temporal types.
Attributes
- Inherited from:
- EnvReads
- Supertypes
-
class Objecttrait Matchableclass Any
Deserializer for java.util.UUID
Value members
Concrete methods
Returns an instance which uses f
as Reads.reads function.
Returns a JsError(cause)
for any JSON value read.
Returns a JsError(cause)
for any JSON value read.
import play.api.libs.json.Reads
val r: Reads[String] = Reads.failed[String]("Failure message")
Attributes
- See also
-
pure
Returns a JsSuccess(a)
(with root path) for any JSON value read.
Returns a JsSuccess(a)
(with root path) for any JSON value read.
import play.api.libs.json.Reads
val r: Reads[String] = Reads.pure("foo")
Attributes
- See also
- Definition Classes
Inherited methods
builds a JsErrorObj JsObject { VAL : "current known erroneous jsvalue", ERR : "the i18n key of the error msg", ARGS : "the args for the error msg" (JsArray) }
builds a JsErrorObj JsObject { VAL : "current known erroneous jsvalue", ERR : "the i18n key of the error msg", ARGS : "the args for the error msg" (JsArray) }
Attributes
- Inherited from:
- DefaultReads
Deserializer for a Map[Char, V]
Reads for the java.util.Date
type.
Reads for the java.util.Date
type.
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks
- pattern
-
a date pattern, as specified in
java.text.SimpleDateFormat
.
Attributes
- Inherited from:
- EnvReads
Attributes
- Inherited from:
- ConstraintReads
Reads for scala.Enumeration
types using the name.
Reads for scala.Enumeration
types using the name.
Value parameters
- enum
-
a
scala.Enumeration
.
Attributes
- Inherited from:
- DefaultReads
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- ConstraintReads
Reads for the java.time.Instant
type.
Reads for the java.time.Instant
type.
Type parameters
- T
-
Type of argument to instantiate date parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
Typeclass instance based on
parsing
- parsing
-
Argument to instantiate date parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.instantReads val customReads1 = instantReads("dd/MM/yyyy, HH:mm:ss") val customReads2 = instantReads(DateTimeFormatter.ISO_INSTANT) val customReads3 = instantReads(DateTimeFormatter.ISO_INSTANT, _.drop(1))
- Inherited from:
- EnvReads
Deserializer of Java Duration from an integer (long) number, using the specified temporal unit.
Deserializer of Java Duration from an integer (long) number, using the specified temporal unit.
Attributes
- Inherited from:
- EnvReads
Attributes
- Inherited from:
- PathReads
Attributes
- Inherited from:
- PathReads
Attributes
- Inherited from:
- PathReads
Attributes
- Inherited from:
- PathReads
Attributes
- Inherited from:
- ConstraintReads
Reads for the java.time.LocalDate
type.
Reads for the java.time.LocalDate
type.
Type parameters
- T
-
Type of argument to instantiate date parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
Typeclass instance based on
parsing
- parsing
-
Argument to instantiate date parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.localDateReads val customReads1 = localDateReads("dd/MM/yyyy, HH:mm:ss") val customReads2 = localDateReads(DateTimeFormatter.ISO_DATE) val customReads3 = localDateReads(DateTimeFormatter.ISO_DATE, _.drop(1))
- Inherited from:
- EnvReads
Reads for the java.time.LocalDateTime
type.
Reads for the java.time.LocalDateTime
type.
Type parameters
- T
-
Type of argument to instantiate date/time parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
Typeclass instance based on
parsing
- parsing
-
Argument to instantiate date/time parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.localDateTimeReads val customReads1 = localDateTimeReads("dd/MM/yyyy, HH:mm:ss") val customReads2 = localDateTimeReads(DateTimeFormatter.ISO_DATE_TIME) val customReads3 = localDateTimeReads( DateTimeFormatter.ISO_DATE_TIME, _.drop(1))
- Inherited from:
- EnvReads
Reads for the java.time.LocalTime
type.
Reads for the java.time.LocalTime
type.
Type parameters
- T
-
Type of argument to instantiate time parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
Typeclass instance based on
parsing
- parsing
-
Argument to instantiate time parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.localTimeReads val customReads1 = localTimeReads("dd/MM/yyyy, HH:mm:ss") val customReads2 = localTimeReads(DateTimeFormatter.ISO_TIME) val customReads3 = localTimeReads(DateTimeFormatter.ISO_TIME, _.drop(1))
- Inherited from:
- EnvReads
Attributes
- Inherited from:
- ConstraintReads
Defines a maximum value for a Reads. Combine with min
using andKeep
, e.g. .read(Reads.min(0.1) andKeep Reads.max(1.0))
.
Defines a maximum value for a Reads. Combine with min
using andKeep
, e.g. .read(Reads.min(0.1) andKeep Reads.max(1.0))
.
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- ConstraintReads
Defines a minimum value for a Reads. Combine with max
using andKeep
, e.g. .read(Reads.min(0) andKeep Reads.max(100))
.
Defines a minimum value for a Reads. Combine with max
using andKeep
, e.g. .read(Reads.min(0) andKeep Reads.max(100))
.
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- ConstraintReads
Reads a Option[T] search optional or nullable field at JsPath (field not found or null is None and other cases are Error).
Reads a Option[T] search optional or nullable field at JsPath (field not found or null is None and other cases are Error).
It runs through JsValue following all JsPath nodes on JsValue:
- If any node in JsPath is not found => returns None
- If any node in JsPath is found with value "null" => returns None
- If the entire path is found => applies implicit Reads[T]
Attributes
- Inherited from:
- PathReads
Reads a Option[T] search nullable field at JsPath (null is None and other cases are Error).
Reads a Option[T] search nullable field at JsPath (null is None and other cases are Error).
It runs through JsValue following all JsPath nodes on JsValue:
- If any node in JsPath is not found => returns default value
- If the last node in JsPath is found with value "null" => returns None
- If the entire path is found => applies implicit Reads[T]
Attributes
- Inherited from:
- PathReads
The simpler of all Reads that just finds an implicit Reads[A] of the expected type
The simpler of all Reads that just finds an implicit Reads[A] of the expected type
Attributes
- Inherited from:
- ConstraintReads
Reads for the java.time.OffsetDateTime
type.
Reads for the java.time.OffsetDateTime
type.
Note: it is intentionally not supported to read an OffsetDateTime from a number.
Type parameters
- T
-
the type of argument to instantiate date/time parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
the implicit conversion based on
parsing
- parsing
-
The argument to instantiate date/time parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.offsetDateTimeReads val customReads1 = offsetDateTimeReads("dd/MM/yyyy, HH:mm:ss (Z)") val customReads2 = offsetDateTimeReads(DateTimeFormatter.ISO_OFFSET_DATE_TIME) val customReads3 = offsetDateTimeReads( DateTimeFormatter.ISO_OFFSET_DATE_TIME, _.drop(1))
- Inherited from:
- EnvReads
Stupidly reads a field as an Option mapping any error (format or missing field) to None
Stupidly reads a field as an Option mapping any error (format or missing field) to None
Attributes
- Inherited from:
- ConstraintReads
very simple optional field Reads that maps "null" to None
very simple optional field Reads that maps "null" to None
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- EnvReads
Attributes
- Inherited from:
- EnvReads
Defines a regular expression constraint for String
values, i.e. the string must match the regular expression pattern
Defines a regular expression constraint for String
values, i.e. the string must match the regular expression pattern
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- PathReads
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- ConstraintReads
Reads for the java.sql.Date
type.
Reads for the java.sql.Date
type.
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks
- pattern
-
a date pattern, as specified in
java.text.SimpleDateFormat
.
Attributes
- Inherited from:
- EnvReads
Reads a JSON object and constructs a tuple of two values, with custom names for the element fields.
Reads a JSON object and constructs a tuple of two values, with custom names for the element fields.
Type parameters
- A
-
the type for the first element
- B
-
the type for the second element
val tuple2Reads: Reads[(String, Int)] = Reads.tuple2[String, Int]("name", "age") val tuple2ExampleJson = Json.obj("name" -> "Alice", "age" -> 25) val tuple2Result: JsResult[(String, Int)] = tuple2Reads.reads(tuple2ExampleJson) // JsSuccess(("Alice", 25))
Value parameters
- name1
-
the name of the first element
_1
- name2
-
the name of the second element
_2
Attributes
- Inherited from:
- DefaultReads
Reads a JSON object and constructs a tuple of three values, with custom names for the element fields.
Reads a JSON object and constructs a tuple of three values, with custom names for the element fields.
Type parameters
- A
-
the type for the first element
- B
-
the type for the second element
- C
-
the type for the third element
val tuple3Reads: Reads[(String, Int, Boolean)] = Reads.tuple3[String, Int, Boolean]("name", "age", "isStudent") val tuple3ExampleJson: JsValue = Json.obj("name" -> "Alice", "age" -> 25, "isStudent" -> true) val tuple3Result: JsResult[(String, Int, Boolean)] = tuple3Reads.reads(tuple3ExampleJson) // JsSuccess(("Alice", 25, true))
Value parameters
- name1
-
the name of the first element
_1
- name2
-
the name of the second element
_2
- name3
-
the name of the third element
_3
Attributes
- Inherited from:
- DefaultReads
Reads a JSON object and constructs a tuple of four values, with custom names for the element fields.
Reads a JSON object and constructs a tuple of four values, with custom names for the element fields.
Type parameters
- A
-
the type for the first element
- B
-
the type for the second element
- C
-
the type for the third element
- D
-
the type for the fourth element
val tuple4Reads: Reads[(String, Int, Boolean, Double)] = Reads.tuple4[String, Int, Boolean, Double]( "name", "age", "isStudent", "score") val tuple4ExampleJson: JsValue = Json.obj( "name" -> "Alice", "age" -> 25, "isStudent" -> true, "score" -> 78.9) val tuple4Result: JsResult[(String, Int, Boolean, Double)] = tuple4Reads.reads(tuple4ExampleJson) // JsSuccess(("Alice", 25, true, 78.9))
Value parameters
- name1
-
the name of the first element
_1
- name2
-
the name of the second element
_2
- name3
-
the name of the third element
_3
- name4
-
the name of the fourth element
_4
Attributes
- Inherited from:
- DefaultReads
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- ConstraintReads
Attributes
- Inherited from:
- PathReads
Reads for the java.time.ZonedDateTime
type.
Reads for the java.time.ZonedDateTime
type.
Type parameters
- T
-
Type of argument to instantiate date/time parser
Value parameters
- corrector
-
a simple string transformation function that can be used to transform input String before parsing. Useful when standards are not exactly respected and require a few tweaks. Function
identity
can be passed if no correction is needed. - p
-
Typeclass instance based on
parsing
- parsing
-
Argument to instantiate date/time parser. Actually either a pattern (string) or a formatter (
java.time.format.DateTimeFormatter
)
Attributes
- See also
-
DefaultWrites.TemporalFormatter
import java.time.format.DateTimeFormatter import play.api.libs.json.Reads.zonedDateTimeReads val customReads1 = zonedDateTimeReads("dd/MM/yyyy, HH:mm:ss") val customReads2 = zonedDateTimeReads(DateTimeFormatter.ISO_DATE_TIME) val customReads3 = zonedDateTimeReads( DateTimeFormatter.ISO_DATE_TIME, _.drop(1))
- Inherited from:
- EnvReads
Inherited fields
Deserializer of Java Duration from a number of milliseconds.
Deserializer of Java Period from a number (integer) of days.
Deserializer of Java Period from a number (integer) of months.
Deserializer of Java Period from a number (integer) of weeks.
Deserializer of Java Period from a number (integer) of years.
Deserializer for a Locale
from an object representation
Implicits
Implicits
Inherited implicits
Deserializer for Array[T] types.
the default implicit java.util.Date reads
The default typeclass to reads java.time.Instant
from JSON. Accepts instant formats as '2011-12-03T10:15:30Z', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
The default typeclass to reads java.time.Instant
from JSON. Accepts instant formats as '2011-12-03T10:15:30Z', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
Attributes
- Inherited from:
- EnvReads
Deserializer of Java Duration, from either a time-based amount of time (string representation such as '34.5 seconds'), or from a number of milliseconds (see javaDurationMillisReads).
Deserializer of Java Duration, from either a time-based amount of time (string representation such as '34.5 seconds'), or from a number of milliseconds (see javaDurationMillisReads).
Attributes
- See also
-
java.time.Duration
DefaultJavaPeriodReads if you want to use java.time.Period instead.
- Inherited from:
- EnvReads
Deserializer of Java Period, from either a time-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days' or from a number of days (see javaPeriodDaysReads).
Deserializer of Java Period, from either a time-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days' or from a number of days (see javaPeriodDaysReads).
Attributes
- See also
-
java.time.Period
DefaultJavaDurationReads if you want to use java.time.Duration instead.
- Inherited from:
- EnvReads
The default typeclass to reads java.time.LocalDate
from JSON. Accepts date formats as '2011-12-03'.
The default typeclass to reads java.time.LocalDate
from JSON. Accepts date formats as '2011-12-03'.
Attributes
- Inherited from:
- EnvReads
The default typeclass to reads java.time.LocalDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
The default typeclass to reads java.time.LocalDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
Attributes
- Inherited from:
- EnvReads
The default typeclass to reads java.time.LocalTime
from JSON. Accepts date formats as '10:15:30' (or '10:15').
The default typeclass to reads java.time.LocalTime
from JSON. Accepts date formats as '10:15:30' (or '10:15').
Attributes
- Inherited from:
- EnvReads
The default typeclass to reads java.time.OffsetDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
The default typeclass to reads java.time.OffsetDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
Attributes
- Inherited from:
- EnvReads
the default implicit SqlDate reads
The default typeclass to reads java.time.ZonedDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
The default typeclass to reads java.time.ZonedDateTime
from JSON. Accepts date/time formats as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.
Attributes
- Inherited from:
- EnvReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Attributes
- Inherited from:
- GeneratedReads
Reads for the java.time.ZoneId
type.
Deserializer for BigDecimal
Deserializer for BigDecimal
Attributes
- Inherited from:
- LowPriorityDefaultReads
Deserializer for a Locale
from a IETF BCP 47 string representation
Deserializer for a Locale
from a IETF BCP 47 string representation
Attributes
- Inherited from:
- EnvReads
Deserializer for a Map[String,V]
Deserializer for a Map[K,V]
Generic deserializer for collections types.
Deserializer for java.net.URI
Attributes
- Inherited from:
- DefaultReads