一个简单的递归算法
string extract_json(std::string& str_in)
{
std::string temp;
std::string temp1;
int x;
int y;
x = str_in.find("{");
if (x != str_in.npos)
{
y = str_in.find("}");
if (y != str_in.npos) {
y = str_in.find("}", y + 1);
temp = (str_in.substr(x, y-x+1));
temp1 = str_in.substr(y + 1, str_in.length());
temp += (extract_json((temp1)));
return temp;
}
}
else {
return "";
}
}