reactivemongo.play.json.compat.json2bson
Implicit conversions for handler types
from play.api.libs.json
to reactivemongo.api.bson
.
import reactivemongo.play.json.compat.json2bson._
def foo[T](jw: play.api.libs.json.OWrites[T]) = {
val w: reactivemongo.api.bson.BSONDocumentWriter[T] = jw
w
}
'''Note:''' Importing both json2bson
& bson2json
can lead to diverging implicits in Scala 2.11
(see HandlerConverterSpec211
).
Implicits
Inherited implicits
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
}
- Inherited from:
- Json2BsonConverters (hidden)
Implicitly provides a BSON document reader if T
is a case class,
or a sealed trait (see DocumentClass
).
Implicitly provides a BSON document reader if T
is a case class,
or a sealed trait (see DocumentClass
).
- Inherited from:
- LowPriority2Json2BsonConverters (hidden)
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)
- Inherited from:
- LowPriority3Json2BsonConverters (hidden)
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]]
- See also:
toDocumentWriterConv
- Inherited from:
- LowPriority1Json2BsonConverters (hidden)
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
}
- Inherited from:
- LowPriority1Json2BsonConverters (hidden)
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]]
- See also:
toDocumentWriterConv
- Inherited from:
- LowPriority3Json2BsonConverters (hidden)
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
- See also:
toDocumentWriterConv
- Inherited from:
- LowPriority2Json2BsonConverters (hidden)
import play.api.libs.json.JsValue
import reactivemongo.api.bson.BSONWriter
// Considering Writes[JsValue] provided by Play JSON,
// with compatibility ...
import reactivemongo.play.json.compat.json2bson._
def canResolve: BSONWriter[JsValue] = implicitly[BSONWriter[JsValue]]
- Inherited from:
- LowPriority3Json2BsonConverters (hidden)