Skip to content

Commit be7e7ed

Browse files
committed
Handle nested JSON objects with a key stack
1 parent fa4f7ec commit be7e7ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

JSONResponse.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct ResponseHandler
197197

198198
bool Key(const Ch* str, rapidjson::SizeType /*length*/, bool /*copy*/)
199199
{
200-
_key = str;
200+
_keyStack.push(str);
201201
return true;
202202
}
203203

@@ -225,7 +225,8 @@ struct ResponseHandler
225225
switch (_responseStack.top().type())
226226
{
227227
case Type::Map:
228-
_responseStack.top().emplace_back(std::move(_key), std::move(value));
228+
_responseStack.top().emplace_back(std::move(_keyStack.top()), std::move(value));
229+
_keyStack.pop();
229230
break;
230231

231232
case Type::List:
@@ -238,7 +239,7 @@ struct ResponseHandler
238239
}
239240
}
240241

241-
std::string _key;
242+
std::stack<std::string> _keyStack;
242243
std::stack<Value> _responseStack;
243244
};
244245

0 commit comments

Comments
 (0)