I have the following stored in a string. I want to fetch the value of "errorType" from this. How can I do that using RapidJson?
{
"id": "9a1eaff0-5339-49ff-86cb-9c76809b3d48",
"timestamp": "2016-07-21T16:11:27.995Z",
"result": {
"source": "agent",
"resolvedQuery": "current time",
"contexts": [],
"metadata": {},
"fulfillment": {
"speech": ""
},
"score": 0.0
},
"status": {
"code": 200,
"errorType": "success"
},
"asr": {
"current time": 0.9035825
},
"sessionId": "1234567890"
}
I tried using this code, but it didn't work:
const std::string s = json;
regex rgx(".*\"errorType\":\s\"(\\w+)\".*");
smatch match;
if (std::regex_search(s.begin(), s.end(), match, rgx))
printf("Value of errortype is : %s\n", match[1]);
It's not printing any value since it didn't work.
How can I fix this problem?
I want to avoid using any JSON parser. But I am flexible with my implementation.