Implicit conversion from new BSONDocumentHandler
to Play JSON.
Implicit conversion from new BSONDocumentHandler
to Play JSON.
import reactivemongo.play.json.compat. bson2json.fromDocumentHandlerConv def bar[T](bh: reactivemongo.api.bson.BSONDocumentHandler[T]) = { val h: play.api.libs.json.OFormat[T] = bh h }
Resolves a OWrites
provided a BSON document writer is found.
Resolves a OWrites
provided a BSON document writer is found.
import play.api.libs.json.OWrites import reactivemongo.play.json.compat.bson2json def bar[T: reactivemongo.api.bson.BSONDocumentWriter]: OWrites[T] = bson2json.fromDocumentWriter[T]
import reactivemongo.play.json.compat.bson2json.fromDocumentWriterConv def bar[T](lw: reactivemongo.api.bson.BSONDocumentWriter[T]) = { val w: play.api.libs.json.OWrites[T] = lw w }
Provided there is a BSON reader, a JSON one is resolved.
Provided there is a BSON reader, a JSON one is resolved.
import play.api.libs.json.Reads import reactivemongo.api.bson.BSONReader import reactivemongo.play.json.compat.bson2json.fromReader def foo[T: BSONReader]: Reads[T] = implicitly[Reads[T]]
Provided there is a BSON writer, resolves a JSON one.
Provided there is a BSON writer, resolves a JSON one.
import play.api.libs.json.Writes import reactivemongo.api.bson.BSONWriter import reactivemongo.play.json.compat.bson2json.fromWriter def foo[T: BSONWriter] = implicitly[Writes[T]] // resolve fromWriter
Implicit conversions for handler types from
reactivemongo.api.bson
toplay.api.libs.json
.Note: Importing both
json2bson
&bson2json
can lead to diverging implicits in Scala 2.11 (seeHandlerConverterSpec211
).