diff options
author | vlad <vlad@driver.xyz> | 2017-07-06 19:52:09 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-07-06 19:52:09 -0700 |
commit | 26de5937aa1a7c5a8dc17b3bc1a8d9bef6d37fb6 (patch) | |
tree | f25f5edff70ccc543373c00ad16803c59bbd0479 /src/main/scala/xyz | |
parent | 4bcb43f31dc2a65e2e0b5dcc07b44054ff7dc231 (diff) | |
download | driver-core-0.13.18.tar.gz driver-core-0.13.18.tar.bz2 driver-core-0.13.18.zip |
Unmarshallers for pubsub messages toov0.13.18
Diffstat (limited to 'src/main/scala/xyz')
-rw-r--r-- | src/main/scala/xyz/driver/core/json.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala index e5173de..1097789 100644 --- a/src/main/scala/xyz/driver/core/json.scala +++ b/src/main/scala/xyz/driver/core/json.scala @@ -216,6 +216,12 @@ object json { implicit val jsValueToStringMarshaller: Marshaller[JsValue, String] = Marshaller.strict[JsValue, String](value => Marshalling.Opaque[String](() => value.compactPrint)) - implicit def valueToStringMarshaller[T](implicit jsonFormat: JsonFormat[T]): Marshaller[T, String] = + implicit def valueToStringMarshaller[T](implicit jsonFormat: JsonWriter[T]): Marshaller[T, String] = jsValueToStringMarshaller.compose[T](jsonFormat.write) + + implicit val stringToJsValueUnmarshaller: Unmarshaller[String, JsValue] = + Unmarshaller.strict[String, JsValue](value => value.parseJson) + + implicit def stringToValueUnmarshaller[T](implicit jsonFormat: JsonReader[T]): Unmarshaller[String, T] = + stringToJsValueUnmarshaller.map[T](jsonFormat.read) } |