Fetch key value from JSON string C++ RapidJson -


i have following stored in string. want fetch value of "errortype" this. how can 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 code, 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 : %s\n", match[1]); 

it's not printing value since didn't work.

how can fix problem?

i want avoid using json parser. flexible implementation.


Comments