Is there a defacto C/C++ library that can handle twitter's streaming
JSON? I tried real quick as a test to see if I can pipe my twitter
feed to boost's JSON parser. No dice. My JSON parser cannot handle the
following lines:
"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"
Removing the offending lines gets a populated property tree. Obviously
not sufficient for twitter. Here is the code in case I declared my
property tree wrong. Help?
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;
}
I can probably fix these two exceptions, but I have a feeling there
may be countably many other issues down the road with this approach.
--
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group:
https://groups.google.com/forum/#!forum/twitter-development-talk