Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert lift-json JValue into MongoDBObject using Casbah?

I'm trying to convert a parsed JSON document in a lift-json's JValue into a Casbah MongoDBObject - is there a way to do this?

like image 570
outside2344 Avatar asked Oct 10 '11 04:10

outside2344


2 Answers

You can convert the lift-json into a Map[String, Any] and then use the implicit asDBObject method on Map:

val record = record.values.asInstanceOf[Map[String, Any]]
record.asDBObject
like image 63
tommy chheng Avatar answered Nov 04 '22 00:11

tommy chheng


Then there is also the net.liftweb.mongodb.JObjectParser with its parse method. The Casbah implicit will convert DBObject into MongoDBObject.

like image 25
Rajish Avatar answered Nov 04 '22 00:11

Rajish