I am using Boost's Property Tree library for storing my json files. For example, I have the following JSON file:
{
"var" : true,
"bar" : -1.56
}
Next I parse this file to ptree
object, do my job and want to store output in MongoDB. For this I convert it back to JSON string:
boost::property_tree::ptree root;
boost::property_tree::read_json(file_path, root);
... // do my job
std::stringstream ss;
boost::property_tree::json_parser::write_json(ss, root);
std::string my_json_string = ss.str();
After this I push my results to MongoDB, by converting JSON string to BSON like this: bsonxx::from_json(my_json_string)
. As result I receive the following entity in database:
{
"var" : "true",
"bar" : "-1.56"
}
Is there a way to insert my JSON string to MongoDB with persistence types?