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

前端 未结 5 844
旧时难觅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 07:58

    The final release of ReactiveMongo 0.11 has been published ("org.reactivemongo" %% "play2-reactivemongo" % "0.11.0.play23").

    As indicated on the updated documentation, for the default BSON/JSON conversions, it's recommended to have: import play.modules.reactivemongo.json._, ImplicitBSONHandlers._.

    0 讨论(0)
  • 2020-11-29 07:59

    Mine worked out after adding: import play.modules.reactivemongo.json._ import play.modules.reactivemongo.json.collection._

    0 讨论(0)
  • 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(...)
    
    0 讨论(0)
  • 2020-11-29 08:10

    try to add

    import reactivemongo.play.json._

    0 讨论(0)
  • 2020-11-29 08:13

    For me adding this import worked.

    import play.modules.reactivemongo.json._
    
    0 讨论(0)
提交回复
热议问题