【发布时间】:2018-07-25 05:17:26
【问题描述】:
我是喷雾 json 应用程序的初学者,我使用 LocalDateTime 作为案例类中的参数类型之一。
import scala.collection.JavaConverters._
import org.apache.commons.imaging.Imaging
import org.joda.time.format.{DateTimeFormat, DateTimeFormatter}
import org.joda.time.{DateTime, LocalDateTime}
import spray.json.DefaultJsonProtocol
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import JodaDateTimeFormats._
import spray.json._
case class ExifMetadata(docName:String, exifOffset:Int, gpsInfo:Int, dateTimeOriginal:LocalDateTime,
gpsLatitudeRef:String, gpsLatitude:Double, gpsLongitudeRef:String, gpsLongitude:Double, gpsDateStamp:LocalDateTime)
trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
implicit val exifMetadataFormat = jsonFormat9(ExifMetadata)
}
但是我不断收到以下错误
could not find implicit value for evidence parameter of type JsonSupport.this.JF[org.joda.time.LocalDateTime]
【问题讨论】:
-
你从哪里得到这个编译错误?
-
当我尝试使用扩展 App 的对象运行上述内容时
-
该对象是否使用您的 JsonSupport 扩展应用程序?它应该。
-
是的,确实如此。对象 ExifExtractor 使用 JsonSupport {} 扩展 App
-
啊,你还需要为LocalDateTime提供一个JsonFormat。会为此写一个答案。
标签: scala spray-json