I've a MongoDB collection where I want to store documents like this:
{
"_id" : ObjectId("52d14842ed0000ed0017cceb"),
"details": {"name" : "Pankaj" , "email_id" :"abc@gmail.com"}
}
But unfortunately here insert into mongo like this:
{
"_id" : ObjectId("52d14842ed0000ed0017cceb"),
"details" : { "name" : "\"Pankaj\"", "email_id" : "\"abc@gmail.com\""}
}
Why this slash coming into mongo! How to remove this slash?
In my code "details" store in Map[String,String]
. And here is how I insert a document:
//BsonDocument
var document = BSONDocument()
details.foreach(e => {document = document.add(BSONDocument(e._1 -> BSONString(e._2)))
}