Writes

play.api.libs.json.Writes
See theWrites companion trait

Default Serializers.

Attributes

Companion
trait
Graph
Supertypes
trait EnvWrites
trait PathWrites
class Object
trait Matchable
class Any
Show all
Self type
Writes.type

Members list

Type members

Inherited classlikes

object BigDecimalWrites extends Writes[BigDecimal]

Serializer for BigDecimal types.

Serializer for BigDecimal types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[BigDecimal]
class Object
trait Matchable
class Any
object BigIntWrites extends Writes[BigInt]

Serializer for BigInt type.

Serializer for BigInt type.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[BigInt]
class Object
trait Matchable
class Any
object BigIntegerWrites extends Writes[BigInteger]

Serializer for BigInteger type.

Serializer for BigInteger type.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[BigInteger]
class Object
trait Matchable
class Any
object BooleanWrites extends Writes[Boolean]

Serializer for Boolean types.

Serializer for Boolean types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Boolean]
class Object
trait Matchable
class Any
object ByteWrites extends Writes[Byte]

Serializer for Byte types.

Serializer for Byte types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Byte]
class Object
trait Matchable
class Any
object DoubleWrites extends Writes[Double]

Serializer for Double types.

Serializer for Double types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Double]
class Object
trait Matchable
class Any
object FloatWrites extends Writes[Float]

Serializer for Float types.

Serializer for Float types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Float]
class Object
trait Matchable
class Any
object IntWrites extends Writes[Int]

Serializer for Int types.

Serializer for Int types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Int]
class Object
trait Matchable
class Any
object LongWrites extends Writes[Long]

Serializer for Long types.

Serializer for Long types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Long]
class Object
trait Matchable
class Any
object ShortWrites extends Writes[Short]

Serializer for Short types.

Serializer for Short types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[Short]
class Object
trait Matchable
class Any
object StringWrites extends Writes[String]

Serializer for String types.

Serializer for String types.

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[String]
class Object
trait Matchable
class Any
object UuidWrites extends Writes[UUID]

Serializer for java.util.UUID

Serializer for java.util.UUID

Attributes

Inherited from:
DefaultWrites
Supertypes
trait Writes[UUID]
class Object
trait Matchable
class Any

Deprecated and Inherited classlikes

object DefaultDateWrites extends Writes[Date]

Attributes

Deprecated
true
Inherited from:
DefaultWrites
Supertypes
trait Writes[Date]
class Object
trait Matchable
class Any
object JsValueWrites extends Writes[JsValue]

Attributes

Deprecated
true
Inherited from:
DefaultWrites
Supertypes
trait Writes[JsValue]
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[A](f: A => JsValue): Writes[A]

Returns an instance which uses f as Writes.writes function.

Returns an instance which uses f as Writes.writes function.

Attributes

def transform[A](w: Writes[A])(f: (A, JsValue) => JsValue): Writes[A]

Transforms the resulting JsValue using the given function, which is also applied with the initial input. def transform(transformer: (A, JsValue) => JsValue): Writes[A] = Writes[A] { a => transformer(a, this.writes(a)) }

Transforms the resulting JsValue using the given function, which is also applied with the initial input. def transform(transformer: (A, JsValue) => JsValue): Writes[A] = Writes[A] { a => transformer(a, this.writes(a)) }

Value parameters

f

the transformer function

w

the initial writer

Attributes

Inherited methods

def at[A](path: JsPath)(implicit wrs: Writes[A]): OWrites[A]

Attributes

Inherited from:
PathWrites
def dateWrites(pattern: String): Writes[Date]

Serializer for java.util.Date

Serializer for java.util.Date

Value parameters

pattern

the pattern used by SimpleDateFormat

Attributes

Inherited from:
DefaultWrites
def jsPick(path: JsPath): Writes[JsValue]

Attributes

Inherited from:
PathWrites

Attributes

Inherited from:
PathWrites

Attributes

Inherited from:
PathWrites
def list[A](implicit writes: Writes[A]): Writes[List[A]]

Attributes

Inherited from:
ConstraintWrites
def map[A](implicit writes: Writes[A]): OWrites[Map[String, A]]

Attributes

Inherited from:
ConstraintWrites
def nullable[A](path: JsPath)(implicit wrs: Writes[A]): OWrites[Option[A]]

writes a optional field in given JsPath : if None, doesn't write field at all. Please note we do not write "null" but simply omit the field when None If you want to write a "null", use ConstraintWrites.optionWithNull[A]

writes a optional field in given JsPath : if None, doesn't write field at all. Please note we do not write "null" but simply omit the field when None If you want to write a "null", use ConstraintWrites.optionWithNull[A]

Attributes

Inherited from:
PathWrites
def of[A](implicit w: Writes[A]): Writes[A]

Attributes

Inherited from:
ConstraintWrites
def optionWithNull[A](implicit wa: Writes[A]): Writes[Option[A]]

Pure Option Writer[T] which writes "null" when None which is different from JsPath.writeNullable which omits the field when None

Pure Option Writer[T] which writes "null" when None which is different from JsPath.writeNullable which omits the field when None

Attributes

Inherited from:
ConstraintWrites
def pruned[A]: Writes[A]

Attributes

Inherited from:
ConstraintWrites
def pure[A](fixed: => A)(implicit wrs: Writes[A]): Writes[JsValue]

Attributes

Inherited from:
ConstraintWrites
def pure[A](path: JsPath, fixed: => A)(implicit wrs: Writes[A]): OWrites[JsValue]

Attributes

Inherited from:
PathWrites
def seq[A](implicit writes: Writes[A]): Writes[Seq[A]]

Attributes

Inherited from:
ConstraintWrites
def set[A](implicit writes: Writes[A]): Writes[Set[A]]

Attributes

Inherited from:
ConstraintWrites

Deprecated and Inherited methods

def iterableWrites[A, M <: (Iterable)](implicit w: Writes[A]): Writes[M[A]]

Serializer for Iterable types.

Serializer for Iterable types.

Deprecated due to incompatibility with non _[_] shapes, #368.

Attributes

Deprecated
true
Inherited from:
LowPriorityWrites
def pruned[A](implicit w: Writes[A]): Writes[A]

Attributes

Deprecated
true
Inherited from:
ConstraintWrites
def sqlDateWrites(pattern: String): Writes[Date]

Serializer for java.sql.Date

Serializer for java.sql.Date

Value parameters

pattern

the pattern used by SimpleDateFormat

Attributes

Deprecated
true
Inherited from:
DefaultWrites
def traversableWrites[A : Writes]: Writes[Iterable[A]]

Attributes

Deprecated
true
Inherited from:
LowPriorityWrites

Concrete fields

Givens

Inherited givens

given enumNameWrites[E <: Enumeration](using e: ValueOf[E]): Writes[Value]

Serializer for scala.Enumeration by name.

Serializer for scala.Enumeration by name.

Attributes

Inherited from:
EnumerationWrites (hidden)

Implicits

Implicits

implicit val contravariantfunctorWrites: ContravariantFunctor[Writes]

Inherited implicits

implicit val NoneWrites: Writes[None.type]

Serializer for JsNull.

Serializer for JsNull.

import play.api.libs.json.Json

Json.obj("foo" -> None)
// equivalent to Json.obj("foo" -> JsNull)

Attributes

Inherited from:
DefaultWrites
implicit def OptionWrites[T](implicit fmt: Writes[T]): Writes[Option[T]]

Serializer for Option.

Serializer for Option.

Attributes

Inherited from:
DefaultWrites
implicit def Tuple10W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple11W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple12W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple13W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple14W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple15W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple16W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple17W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple18W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes, T18 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple19W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes, T18 : Writes, T19 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple1W[T1 : Writes]: Writes[(T1)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple20W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes, T18 : Writes, T19 : Writes, T20 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple21W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes, T18 : Writes, T19 : Writes, T20 : Writes, T21 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple22W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes, T10 : Writes, T11 : Writes, T12 : Writes, T13 : Writes, T14 : Writes, T15 : Writes, T16 : Writes, T17 : Writes, T18 : Writes, T19 : Writes, T20 : Writes, T21 : Writes, T22 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple2W[T1 : Writes, T2 : Writes]: Writes[(T1, T2)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple3W[T1 : Writes, T2 : Writes, T3 : Writes]: Writes[(T1, T2, T3)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple4W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes]: Writes[(T1, T2, T3, T4)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple5W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes]: Writes[(T1, T2, T3, T4, T5)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple6W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes]: Writes[(T1, T2, T3, T4, T5, T6)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple7W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple8W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8)]

Attributes

Inherited from:
GeneratedWrites
implicit def Tuple9W[T1 : Writes, T2 : Writes, T3 : Writes, T4 : Writes, T5 : Writes, T6 : Writes, T7 : Writes, T8 : Writes, T9 : Writes]: Writes[(T1, T2, T3, T4, T5, T6, T7, T8, T9)]

Attributes

Inherited from:
GeneratedWrites
implicit def arrayWrites[T : Writes]: Writes[Array[T]]

Serializer for Array[T] types.

Serializer for Array[T] types.

Attributes

Inherited from:
DefaultWrites
implicit def defaultDateWrites[T <: Date]: Writes[T]

Default Serializer java.util.Date -> JsNumber(d.getTime (nb of ms))

Default Serializer java.util.Date -> JsNumber(d.getTime (nb of ms))

Attributes

Inherited from:
DefaultWrites
implicit def genericMapWrites[V, M <: (Map)](implicit w: Writes[V]): OWrites[M[String, V]]

Serializer for Map[String,V] types.

Serializer for Map[String,V] types.

Attributes

Inherited from:
DefaultWrites
implicit def iterableWrites2[A, I](implicit ev: I <:< Iterable[A], w: Writes[A]): Writes[I]

Serializer for Iterable types.

Serializer for Iterable types.

Attributes

Inherited from:
LowPriorityWrites
implicit def jsValueWrites[T <: JsValue]: Writes[T]

Serializer for JsValues.

Serializer for JsValues.

Attributes

Inherited from:
DefaultWrites
implicit def keyMapWrites[K : KeyWrites, V : Writes, M <: (Map)]: OWrites[M[K, V]]

Attributes

Inherited from:
DefaultWrites
implicit def rangeWrites[T <: Range]: Writes[T]

Serializer for scala.collection.immutable.Range (aka specialized Seq of Int).

Serializer for scala.collection.immutable.Range (aka specialized Seq of Int).

Attributes

Inherited from:
DefaultWrites
implicit def someWrites[T](implicit w: Writes[T]): Writes[Some[T]]

If Some is directly used (not as Option).

If Some is directly used (not as Option).

import play.api.libs.json.{ Json, Writes }

def foo[T: Writes](writeableValue: T) =
 Json.obj("foo" -> Some(writeableValue))
 // equivalent to Json.obj("foo" -> writeableValue)

Attributes

Inherited from:
DefaultWrites
implicit def stringableWrites[T](implicit conv: T => String): Writes[T]

Serializer for any type that is provided an implicit conversion to String (e.g. tagged types).

Serializer for any type that is provided an implicit conversion to String (e.g. tagged types).

Attributes

Inherited from:
LowPriorityWrites
implicit val uriWrites: Writes[URI]

Serializer for java.net.URI

Serializer for java.net.URI

Attributes

Inherited from:
LowPriorityWrites

Deprecated and Inherited implicits

implicit def mapWrites[V : Writes]: OWrites[Map[String, V]]

Serializer for Map[String,V] types.

Serializer for Map[String,V] types.

Attributes

Deprecated
true
Inherited from:
DefaultWrites