I'm receiving an JSON graph (payload) from the client, so at the web api I get a JsValue. I simply want to take that, decorate it with a couple of fields and store it in Mongo. Something like this:
case class Plan(_id: ObjectId, name: String, payload: JsValue)
{
"_id" = 12345,
"name" : "test model",
"payload" : {a JSON graph}
}
From JsValue to database...
builder += "payload" -> JSON.parse(Json.stringify(model.payload))
From database back to a JsValue...
payload = Json.parse(dbo.as[MongoDBList]("payload").toString))
While it works to go from JsValue -> String -> MongoDBObject, I have two valid typed objects and I have to use an untyped intermediate format to go from one to another.