My application receives a JSON response from a server and sometimes the JSON response has format issues. so I would like to parse this JSON response as a string. Below is the sample JSON response I'm dealing with.
[{
"Id": "0000001",
"fName": "ABCD",
"lName": "ZY",
"salary": 1000
},
{
"Id": "0000002",
"fName": "EFGH",
"lName": "XW",
"salary": 1010
},
{
"Id": "0000003",
"fName": "IJKL",
"lName": "VU",
"salary": 1020
}]
I want to get the content between the braces into multiple vectors. so that I can easily iterate and parse the data. I tried using
str.substr(first, last - first)
, but this will return only one string where I need all possible matches. And I tried using regex as below and it is throwing below exception. Please help me!
(regex_error(error_badrepeat): One of *?+{ was not preceded by a valid regular expression)
std::regex _regex("{", "}");
std::smatch match;
while (std::regex_search(GetScanReportURL_Res, match, _regex))
{
std::cout << match.str(0);
}
"fName": "{},"is going to ruin your day though.