reactivemongo.play.json.compat.dsl
DSL for MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl._
Json.obj("int" -> int(1), "double" -> double(2.3D))
// {
// "int": { "$numberInt": "1" },
// "double": { "$numberDouble": "2.3" }
// }
Value members
Concrete methods
Represents a scala.BigDecimal value using MongoDB Extended JSON syntax (v2).
Represents a scala.BigDecimal value using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl.decimal
Json.obj("field" -> decimal(BigDecimal("4")))
// { "field": { "$numberDecimal": "4" } }
Represents a scala.Double value using MongoDB Extended JSON syntax (v2).
Represents a scala.Double value using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl.double
Json.obj("field" -> double(3.4D))
// { "field": { "$numberDouble": "3.4" } }
Represents a scala.Int value using MongoDB Extended JSON syntax (v2).
Represents a scala.Int value using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl.int
Json.obj("field" -> int(1))
// { "field": { "$numberInt": "1" } }
Represents a scala.Long value using MongoDB Extended JSON syntax (v2).
Represents a scala.Long value using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl.long
Json.obj("field" -> long(2L))
// { "field": { "$numberLong": "2" } }
Represents a object ID using MongoDB Extended JSON syntax (v2).
Represents a object ID using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.api.bson.BSONObjectID
import reactivemongo.play.json.compat.dsl.objectID
Json.obj("field" -> objectID(BSONObjectID.generate()))
// { "field": { "$oid": "...binary repr" } }
Represents a symbol using MongoDB Extended JSON syntax (v2).
Represents a symbol using MongoDB Extended JSON syntax (v2).
import play.api.libs.json.Json
import reactivemongo.play.json.compat.dsl.symbol
Json.obj("field" -> symbol("sym_name"))
// { "field": { "$symbol": "sym_name" } }