materialize Reads for the class
materialize Reads for the class
materialize both Reads and Writes for the class
materialize both Reads and Writes for the class
materialize Writes for the class
materialize Writes for the class
Default Play's behavior for Option
s is that when the value is None
then it does not appear in
the resulting JSON.
Default Play's behavior for Option
s 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.
// 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
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
@protocol.io case class Foo( value: String )
Foo( "something" )
transformed to JSON produces JsString( "something" )
@protocol.io @protocol.strict case class Foo( value: String )
Foo( "something" )
transformed to JSON produces {"value":"something"}
(Since version ) see corresponding Javadoc for more information.
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:
And then the use is
However, this class can be also used directly.