Conversion API from BSON to JSON values
JSON representation for numbers
JSON representation for numbers
Conversion API from BSON to JSON values
Implicit conversions for value types between
play.api.libs.json
and reactivemongo.api.bson
.
Implicit conversions for value types between
play.api.libs.json
and reactivemongo.api.bson
.
import play.api.libs.json.JsValue import reactivemongo.api.bson.BSONValue import reactivemongo.play.json.compat.ValueConverters._ def foo(v: BSONValue): JsValue = implicitly[JsValue](v) // ValueConverters.fromValue def bar(v: JsValue): BSONValue = implicitly[BSONValue](v) // ValueConverters.toValue
Note: Logger reactivemongo.api.play.json.ValueConverters
can be used to debug.
Compatibility alias for play.api.libs.json.JsFalse
(DO NOT USE)
Compatibility alias for play.api.libs.json.JsFalse
(DO NOT USE)
Compatibility alias for play.api.libs.json.JsTrue
(DO NOT USE)
Compatibility alias for play.api.libs.json.JsTrue
(DO NOT USE)
Implicit conversions for value types between
play.api.libs.json
and reactivemongo.api.bson
,
using lax conversions.
See compat$ and ValueConverters.
See compat$ and ValueConverters.
Note that as there is not a JSON equivalent for each BSON value
(BSONDateTime
, or even distinction between BSON long/int).
So for example, using the default JSON handlers,
a same Long
property can be written in some documents
as BSON long (NumberLong
), and in some other as BSON integer
(see ValueConverters.toNumber), which is ok to read all these documents,
but can impact the MongoDB queries (same for date/time values that
will be serialized as BSON string, rather than BSON date/time or timestamp).
See syntax:
See syntax:
{ "$binary":
{
"base64": "<payload>",
"subType": "<t>"
}
}
See syntax:
See syntax:
{ "$date": { "$numberLong": "<millis>" } }
See syntax:
See syntax:
{
"$code": "<javascript>",
"$scope": { }
}
See syntax:
See syntax:
{ "$maxKey": 1 }
See syntax:
See syntax:
{ "$minKey": 1 }
See syntax:
See syntax:
{ "$regularExpression":
{
"pattern": "<regexPattern>",
"options": "<options>"
}
}
See syntax:
See syntax:
{ "$timestamp": {"t": <t>, "i": } }`
See syntax:
See syntax:
{ "$undefined": true }
import play.api.libs.json._ import reactivemongo.api.bson._ import reactivemongo.play.json.compat.lax._ Json.obj("_id" -> BSONObjectID.generate()) // objectIdWrites // { "_id": "as_string_instead_of_ObjectId" }