3
我真的很快作爲測試,看看我是否可以管我的twitter飼料,以提升的JSON解析器。沒有骰子。我的JSON解析器不能處理下面幾行:boost :: property_tree :: json_parser :: read_json&Twitter?
"profile_background_image_url":"http:\/\/a2.twimg.com\/profile_background_images\/4531792\/wallpaper_stock.jpg",
"url":"http:\/\/on.fb.me\/bShBVQ",
exception error: "invalid escape sequence"
"id":86162751646482432,
exception error: "expected value"
刪除違規線得到一個人口屬性樹。顯然不足以用於推特。這裏是我聲明屬性樹錯誤的情況下的代碼。幫幫我?
int main (int argc, char * const argv[])
{
boost::property_tree::basic_ptree<std::string,std::string> pt;
std::ifstream f;
f.open("testJSON2a.txt");
if(!f.is_open())
{
std::cout << "Error";
return 0;
}
try
{
boost::property_tree::json_parser::read_json(f,pt);
boost::property_tree::basic_ptree<std::string,std::string>::const_iterator iter = pt.begin(),iterEnd = pt.end();
for(;iter != iterEnd;++iter)
{
std::cout << iter->first << " " << iter->second.get_value<std::string>() << std::endl;
}
}
catch(boost::property_tree::json_parser::json_parser_error &je)
{
std::cout << "Error parsing: " << je.filename() << " on line: " << je.line() << std::endl;
std::cout << je.message() << std::endl;
}
return 0;
}
網頁實際上重新格式化的URI應該是:「url」:「http:\/\/on.fb.me \/bShBVQ」, – user805547