0

I am newbie to mongodb and also to reactive mongo and I'm trying to integrate this example to my project https://github.com/sgodbillon/reactivemongo-demo-app Firstly I would like to work only with class article but when I integrate the model and the controller I get this error:

No Json serializer as JsObject found for type play.api.libs.json.JsObject. Try to implement an implicit OWrites or OFormat for this type.

for this line in the controller:

63    // the cursor of documents
64    val found = collection.find(query).cursor[Article]
Rajeun
  • 721
  • 2
  • 12
  • 37
  • may be there is no implicit reader for `Article`? – andrey.ladniy Mar 17 '16 at 06:17
  • Please show the contents of `query`, this should be a `JsObject`. – Zoltán Mar 17 '16 at 10:09
  • 4
    Have you tried importing `import play.modules.reactivemongo.json._` as stated in this question http://stackoverflow.com/questions/31142366/no-json-serializer-as-jsobject-found-for-type-play-api-libs-json-jsobject? Which version of reactivemongo are you using? – Zoltán Mar 17 '16 at 10:13

1 Answers1

0

Have you implement writes for Article?

simple macros must helps you

implicit val articleWrite = Json.writes[Article]
andrey.ladniy
  • 1,664
  • 1
  • 11
  • 27
  • of course - I'm confused you need writes or format and not reads. I refine answer. You can implement own `OWrites` like `implicit val myWrites: OWrites[A] = new OWrites[A] { def writes(a: A) = Json.obj(...) }` – andrey.ladniy Mar 17 '16 at 10:06