2016-06-10 13 views
0

In meiner app ich https://github.com/fommil/spray-json-shapeless Bibliothek für serializaion bin, aber ich habe ein Problem mit dieser Klasse:JsValue Serialisierung scheitern

case class FooResult(var id: Option[String], jobId: String, completedAt: DateTime, result: JsValue) extends JobResult 

implicit val JobResultFormat: RootJsonFormat[JobResult] = { 
    import shapeless._ 
    cachedImplicit 
} 

Ohne Ergebnisfeld vom Typ JsValue alles funktioniert gut, aber mit ihm, ich habe folgende Ausnahme:

[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] 

Irgendwelche Ratschläge, wie man damit umgeht.

Antwort

0

Ich löste mein Problem, indem ich das Ergebnis auf JsObject änderte und das Projekt vor dem Wiederaufbau säuberte.

Fallklasse FooResult (var id: Option [Zeichenfolge], jobId: String, completedAt: DateTime, Ergebnis: JsObject) erweitert JobResult