No Json serializer as JsObject found for type play.api.libs.json.JsObject

前端 未结 5 868
旧时难觅i
旧时难觅i 2020-11-29 07:47

I have the following code that works in a console app when referencing \"org.reactivemongo\" %% \"play2-reactivemongo\" % \"0.10.5.0.akka23\"

when I upd

5条回答
  •  情歌与酒
    2020-11-29 08:03

    In my case, I was feeding ReactiveMongo (insert) with a JsValue instead than a JsObject. In order to fix it, behind adding import play.modules.reactivemongo.json._, I also had to change my implicit Writes in OWrites:

    from

    implicit val myWrites: Writes[A] = new Writes[A] {
      def writes(a: A) = Json.obj(...)
    

    to

    implicit val myWrites: OWrites[A] = new OWrites[A] {  <-- NOTE THE 'O' before 'Writes'
      def writes(a: A) = Json.obj(...)
    

提交回复
热议问题