object TimestampSerializer extends Serializer[Instant] {
val sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ")
val instantClazz: Class[Instant] = classOf[Instant]
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Instant] = {
case (TypeInfo(`instantClazz`, _), json) => json match {
case JString(s) => sdf.parse(s.replaceAll("""\+(\d\d)(?::(\d\d))""", "+$1$2")).toInstant
case x => throw new MappingException("Can't convert " + x + " to Instant")
}
}
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
case x: Instant => JString(x.toString)
}
}
This is said serializer. The case class that uses an Option[Instant] is needed. The JValue is JNull. Instead of being None it throws an exception.
This is fixed by adding a case JNull => null, but it was not like this before ng.