diff options
author | Jakob Odersky <jakob@odersky.com> | 2018-05-06 13:56:16 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2018-05-08 23:02:39 -0700 |
commit | 8ecae787ff7124b008229d958c579c73649dd9e4 (patch) | |
tree | dad7bea34d9b7ea0f716a783f3b57de491ec959e /common/shared/src/main/scala/ApiProtocol.scala | |
download | scala-triad-8ecae787ff7124b008229d958c579c73649dd9e4.tar.gz scala-triad-8ecae787ff7124b008229d958c579c73649dd9e4.tar.bz2 scala-triad-8ecae787ff7124b008229d958c579c73649dd9e4.zip |
Initial commit
Diffstat (limited to 'common/shared/src/main/scala/ApiProtocol.scala')
-rw-r--r-- | common/shared/src/main/scala/ApiProtocol.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/shared/src/main/scala/ApiProtocol.scala b/common/shared/src/main/scala/ApiProtocol.scala new file mode 100644 index 0000000..5d0e00a --- /dev/null +++ b/common/shared/src/main/scala/ApiProtocol.scala @@ -0,0 +1,12 @@ +package triad + +import java.time.Instant +import spray.json.{DerivedJsonProtocol, JsNumber, JsValue, JsonFormat} + +object ApiProtocol extends DerivedJsonProtocol { + implicit val timestampFormat: JsonFormat[Instant] = new JsonFormat[Instant] { + def read(js: JsValue) = Instant.ofEpochMilli(js.convertTo[Long]) + def write(i: Instant) = JsNumber(i.toEpochMilli) + } + implicit val messageFormat = jsonFormat[Message] +} |