[bug](json)Fix the problem of be down caused by json path ending with \ (#28180)

This commit is contained in:
Liqf
2023-12-15 15:57:08 +08:00
committed by GitHub
parent 088bb80a9c
commit 0f25a4b3c6
4 changed files with 14 additions and 0 deletions

View File

@ -229,12 +229,19 @@ rapidjson::Value* get_json_object(std::string_view json_string, std::string_view
std::vector<JsonPath>* parsed_paths;
std::vector<JsonPath> tmp_parsed_paths;
//Cannot use '\' as the last character, return NULL
if (path_string.back() == '\\') {
document->SetNull();
return document;
}
#ifdef USE_LIBCPP
std::string s(path_string);
auto tok = get_json_token(s);
#else
auto tok = get_json_token(path_string);
#endif
std::vector<std::string> paths(tok.begin(), tok.end());
get_parsed_paths(paths, &tmp_parsed_paths);
if (tmp_parsed_paths.empty()) {