#include <string>
#include <map>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
using boost::property_tree::ptree;
using boost::property_tree::ptree_error;
bool common_ParseJsonData(std::map<std::string, std::string> & odata, std::string &str)
{
try
{
ptree pt;
std::stringstream stream(str);
read_json(stream, pt);
BOOST_FOREACH(auto &v, odata)
{
try
{
v.second = pt.get<std::string>(v.first);
}
catch (ptree_error pt)
{
v.second = "";
}
}
}
catch (ptree_error pt)
{
pt.what();
return false;
}
return true;
}