Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.
/ scala-json-rpc Public archive

Types and play-json Format instances for JSON-RPC 2.0 messages, with application command, response and notification marshalling support.

License

Notifications You must be signed in to change notification settings

dhpiggott/scala-json-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-json-rpc

Build Status codecov Latest Version

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

The CommandCompanion, ResponseCompanion and 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

The JSON-RPC message types are represented by an ADT defined in JsonRpcMessage.scala. The JsonRpcMessage JsonRpcMessageSpec.scala shows how they appear when marshalled to and from JSON.

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.

License

scala-json-rpc is licensed under the Apache 2 License.

About

Types and play-json Format instances for JSON-RPC 2.0 messages, with application command, response and notification marshalling support.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages