From d514c186b505257fbfd631d5a4b707150aa78b7e Mon Sep 17 00:00:00 2001 From: Stewart Stewart Date: Mon, 19 Dec 2016 21:40:02 -0500 Subject: add json formatter for date --- src/main/scala/xyz/driver/core/json.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/scala/xyz') diff --git a/src/main/scala/xyz/driver/core/json.scala b/src/main/scala/xyz/driver/core/json.scala index a3894db..4007e78 100644 --- a/src/main/scala/xyz/driver/core/json.scala +++ b/src/main/scala/xyz/driver/core/json.scala @@ -7,12 +7,14 @@ import akka.http.scaladsl.unmarshalling.Unmarshaller import spray.json.{DeserializationException, JsNumber, _} import xyz.driver.core.revision.Revision import xyz.driver.core.time.Time -import xyz.driver.core.date.Month +import xyz.driver.core.date.{Date, Month} import scala.reflect.runtime.universe._ object json { + import DefaultJsonProtocol._ + def IdInPath[T]: PathMatcher1[Id[T]] = new PathMatcher1[Id[T]] { def apply(path: Path) = path match { case Path.Segment(segment, tail) => Matched(tail, Tuple1(Id[T](segment))) @@ -75,6 +77,8 @@ object json { } } + implicit val dateFormat = jsonFormat3(Date) + def RevisionInPath[T]: PathMatcher1[Revision[T]] = PathMatcher("""[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}""".r) flatMap { string => Some(Revision[T](string)) -- cgit v1.2.3