Types and play-json Format instances for JSON-RPC 2.0 messages, with application command, response and notification marshalling support.
Note that up until version 1.5.0 scala-json-rpc was called play-json-rpc. It was originally developed for use in both the server and client side of Liquidity.
Resolver and library dependency
resolvers += Resolver.bintrayRepo("dhpcs", "maven") libraryDependencies += "com.dhpcs" %% "scala-json-rpc" % "x.y.z"
Command, response and notification marshalling
NotificationCompanion bases defined in MessageCompanions.scala provide readers and writers for hierarchies of application level types. Example use can be seen in MessageCompanionsSpec.scala.
JSON-RPC message types
Note that typical usage does not involve the direct construction of the low level JSON-RPC message types. The recommended approach is to make use of the writers provided by the companion bases as demonstrated in the previously linked marshalling specification.
The companion object for the
JsonRpcMessage trait provides a play-json Format typeclass instance that can read and write "raw"
JsonRpcMessage types. If you are reading messages received over e.g. a websocket connection and thus don't know what message type to expect at a given poiint, you can simply match on the subtype of the result and then use the appropriate application specific companion to unmarshall the content to one of your application protocol's types. Similarly, when marshalling your application protocol's types, you'll first pass them to the appropriate application specific companion and then format the result of that as JSON, implicitly making use of the relevant provided typeclass instance.
scala-json-rpc is licensed under the Apache 2 License.