Implicit conversion from Play JSON OFormat
to the BSON API.
Implicit conversion from Play JSON OFormat
to the BSON API.
import reactivemongo.play.json.compat. json2bson.toDocumentHandlerConv def foo[T](jh: play.api.libs.json.OFormat[T]) = { val h: reactivemongo.api.bson.BSONDocumentHandler[T] = jh h }
Raises a JsError
is the JSON value is not a JsObject
.
Raises a JsError
is the JSON value is not a JsObject
.
import reactivemongo.play.json.compat.json2bson.toDocumentReaderConv def lorem[T](jr: play.api.libs.json.Reads[T]) = toDocumentReaderConv(jr)
Provided there is a Play JSON OWrites
, resolve a document writer.
Provided there is a Play JSON OWrites
, resolve a document writer.
import play.api.libs.json.OWrites import reactivemongo.api.bson.BSONDocumentWriter import reactivemongo.play.json.compat.json2bson.toDocumentWriter def foo[T : OWrites]: BSONDocumentWriter[T] = implicitly[BSONDocumentWriter[T]]
import reactivemongo.play.json.compat. json2bson.toDocumentWriterConv def foo[T](jw: play.api.libs.json.OWrites[T]) = { val w: reactivemongo.api.bson.BSONDocumentWriter[T] = jw w }
Provided there is a Play JSON Reads
, resolve a BSON reader.
Provided there is a Play JSON Reads
, resolve a BSON reader.
import play.api.libs.json.Reads import reactivemongo.api.bson.BSONReader import reactivemongo.play.json.compat.json2bson.toReader def foo[T: Reads]: BSONReader[T] = implicitly[BSONReader[T]]
Converts a Play JSON Reads
to a BSON reader.
Converts a Play JSON Reads
to a BSON reader.
import play.api.libs.json.Reads import reactivemongo.api.bson.BSONReader import reactivemongo.play.json.compat.json2bson.toReaderConv def foo[T](implicit r: Reads[T]): BSONReader[T] = r
Implicit conversions for handler types from
play.api.libs.json
toreactivemongo.api.bson
.Note: Importing both
json2bson
&bson2json
can lead to diverging implicits in Scala 2.11 (seeHandlerConverterSpec211
).