mongodb - efficient way to transform a playframework JsValue to a MongoDBObject -
i'm receiving json graph (payload) client, @ web api jsvalue. want take that, decorate couple of fields , store in mongo. this:
case class plan(_id: objectid, name: string, payload: jsvalue) { "_id" = 12345, "name" : "test model", "payload" : {a json graph} }
from jsvalue database...
builder += "payload" -> json.parse(json.stringify(model.payload))
from database jsvalue...
payload = json.parse(dbo.as[mongodblist]("payload").tostring))
while works go jsvalue -> string -> mongodbobject, have 2 valid typed objects , have use untyped intermediate format go 1 another.
if want store graph string "payload", can of course that.
you may want consider using reactivemongo instead of casbah, along play-reactivemongo, provides direct-to-json capability. have not used play-reactivemongo.
Comments
Post a Comment