Search code examples
mongodbcasbahlift-json

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?


Solution

  • 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