Object

play.api.json

protocol

Related Doc: package json

Permalink

object protocol

Marks a case class to be part of json protocol. The annotation ensures proper creation of context-aware Reads and Writes for the class. The processor adds markup Protocol trait to the class and creates reads and writes implicit within the class companion providing implicit converters into JSON.

This class can be extended to make it local within different namespace. For example, suggested use is:

package foo

case class Context()

object Protocol extends ContextualJson with JsonContext {
  override type Context = foo.Context
  class protocol extends play.api.json.protocol
}

And then the use is

import foo.Protocol._

@protocol case class Foo()

However, this class can be also used directly.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. protocol
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. macro class in extends Annotation with StaticAnnotation

    Permalink

    materialize Reads for the class

    materialize Reads for the class

    Annotations
    @compileTimeOnly( ... )
  2. macro class io extends Annotation with StaticAnnotation

    Permalink

    materialize both Reads and Writes for the class

    materialize both Reads and Writes for the class

    Annotations
    @compileTimeOnly( ... )
  3. macro class out extends Annotation with StaticAnnotation

    Permalink

    materialize Writes for the class

    materialize Writes for the class

    Annotations
    @compileTimeOnly( ... )
  4. class removeNulls extends Annotation with StaticAnnotation

    Permalink

    Default Play's behavior for Options is that when the value is None then it does not appear in the resulting JSON.

    Default Play's behavior for Options is that when the value is None then it does not appear in the resulting JSON. We consider returning null a better choice, however it should allow enabling the default behavior and remove the value when it is None.

    To enable the same behavior as Play uses, annotate your ContextualJson instance with this annotation. When the macro detects this annotation, it removes all optional null values from the JSON.

    Example:
    // this produces nulls when there is none None
    object SimpleJson extends ContextualJson
    // this removes the pair when there is none None as a value
    @removeNulls
    object SimpleJson extends ContextualJson
  5. class strict extends Annotation with StaticAnnotation

    Permalink

    if the object has a single field and is not @strict, it is transformed into a value.

    if the object has a single field and is not @strict, it is transformed into a value. With strict it is still an object

    Non-strict example

    @protocol.io case class Foo( value: String )

    Foo( "something" ) transformed to JSON produces JsString( "something" )

    Strict example

    @protocol.io @protocol.strict case class Foo( value: String )

    Foo( "something" ) transformed to JSON produces {"value":"something"}

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. object contextless

    Permalink
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  17. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped