내 앱 에서 직렬화를 위해 https://github.com/fommil/spray-json-shapeless 라이브러리를 사용 하고 있지만이 클래스에 문제가 있습니다.
case class FooResult(var id: Option[String], jobId: String, completedAt: DateTime, result: JsValue) extends JobResult
implicit val JobResultFormat: RootJsonFormat[JobResult] = {
import shapeless._
cachedImplicit
}
JsValue 유형의 결과 필드가 없으면 모든 것이 잘 작동하지만 다음과 같은 예외가 있습니다.
[error] /home/mgosk/projects/spark-service/spark-rest-api/src/main/scala/com/xxx/http/services/SparkService.scala:134: ambiguous implicit values:
[error] both object JsValueFormat in trait AdditionalFormats of type com.xxx.spark.json.ServiceJsonProtocol.JsValueFormat.type
[error] and method familyFormat in trait LowPriorityFamilyFormats of type [T, Repr](implicit gen: shapeless.LabelledGeneric.Aux[T,Repr], implicit sg: shapeless.Cached[shapeless.Strict[com.xxx.spark.json.ServiceJsonProtocol.WrappedRootJsonFormat[T,Repr]]], implicit tpe: shapeless.Typeable[T])spray.json.RootJsonFormat[T]
[error] match expected type spray.json.JsonFormat[spray.json.JsValue]
그것을 처리하는 방법에 대한 조언.
JsObject
재건하기 전에 결과를 변경 하고 프로젝트를 청소 하여 문제를 해결했습니다 .
case class FooResult(var id: Option[String], jobId: String, completedAt: DateTime, result: JsObject) extends JobResult
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다