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

def decimal(d: BigDecimal): JsObject

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" } }
def double(d: Double): JsObject

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" } }
def int(i: Int): JsObject

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" } }
def long(l: Long): JsObject

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" } }
def objectID(oid: BSONObjectID): JsObject

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" } }
def symbol(name: String): JsObject

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" } }