My input: data.txt
{
"target_url":"www.19lou.com/forum-1637-thread-10031471311655793-1-1.html",
"trespassing_field":{
"ratetype":5,
"spider":{
"prod_name":"name",
"link_src":1
}
}
}
use code:
boost::property_tree::ptree json_tree;
boost::property_tree::read_json("data.txt", json_tree);
std::stringstream json_main_pack;
boost::property_tree::write_json(json_main_pack, json_tree);
LOG(NOTICE) << "json: " << json_main_pack.str();
output:
{
"target_url": "www.19lou.com\/forum-1637-thread-10031471311655793-1-1.html",
"trespassing_field": {
"ratetype": "5",
"spider": {
"prod_name": "name",
"link_src": "1"
}
}
}
write_json() convert integer value to string.It convert "ratetype":5
to "ratetype": "5"
.It is incorrect.
How to convert accurately?Input integer value, then output integer value.