-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
int main(){
Json::Reader reader;
try
{
Json::Value root;
const char* str2 = "{\"uploadid\": \"UP000000\",\"code\":-2105368552146909364,\"msg\": \"\",\"files\":[]}";
if (reader.parse(str2, root))
{
string upload_id = root["uploadid"].asString();
//int code = root["code"].asInt();
string code =root["code"].asString();
string msg = root["msg"].asString();
Json::Value files =root["files"];
{
cout<<"files empty"<<endl;
}
cout<<root.size()<<" "<<upload_id<<" "<<code<<" "<<msg<<endl;
}
}
catch(std::exception e)
{
// (1) it will catch the error show show
cerr << e.what() << endl;
}
catch(std::out_of_range e)
{
// (2) this will also catch the same error if (1) was not there but could
// get you more details if you wanted since its more specific but i have
// not digged into it further
cerr << e.what() << endl;
}
catch(...)
{
// (3) just for sanity check if first two didn't catch it
cerr << "something went wrong";
}
}
Metadata
Metadata
Assignees
Labels
No labels