The library considers context-aware JSON processing.
Marks a case class to be part of json 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.
The library considers context-aware JSON processing. It means that for every data processing it accepts current execution context containing, e.g., user's identity, application state, user's privileges, etc. This enables us to use these contextual data within conditions and transformations to provide/read only data matching these conditions.
Instances of
ContextualJson
implements the protocol and provides Reads and Writes materializers, including context type and implicit conversions. Everywhere we want to use the protocol we have to import everything from our protocol instance.Example
Define the context
Define the protocol
And then we import it everywhere we use the protocol