cannot parse tab correctly : syntax error at line 1 near
phoenixbai opened this issue · 1 comments
phoenixbai commented
picojson cannot parse string with tab character correctly.
e.g.
string query = "{\"words_in\":\"73125410214114\t涂海明-\t-58679576928 发浙江省台州市温岭市浙江省台州市温岭市横峰街道,南翔路57号 \", \"service_consumer_id\":\"NEW2\", \"input_type\":\"text\"}";
map<string, string> features;
picojson::value v;
std::string err;
parse(v, query.begin(), query.end(), &err);
if (!err.empty() || !v.is<picojson::object>()) {
cout << err.c_str() << endl;
return 1;
}
const picojson::value::object& obj = v.get<picojson::object>();
for (picojson::value::object::const_iterator it = obj.begin(); it != obj.end(); it++) {
features[it->first] = it->second.to_str();
cout << it->first << " " << it->second.to_str() << endl;
}
if i remove the tab from string, it works just fine. I try with the latest code on master, result is the same.
what is wrong? how can I fix it ? please help!
phoenixbai commented
replace "\t" with "\\t" works as expected.
though I don't know why yet, i am going to close this.