mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
chore: doc_accessors now parse with json::Path as well (#2615)
chore: replace search path parsing with json::Path Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
8cce14ce85
commit
cbfd5bb7c5
4 changed files with 58 additions and 49 deletions
|
@ -15,9 +15,8 @@
|
|||
|
||||
#include "base/flags.h"
|
||||
#include "base/logging.h"
|
||||
#include "core/json/driver.h"
|
||||
#include "core/json/json_object.h"
|
||||
#include "core/json/jsonpath_grammar.hh"
|
||||
#include "core/json/path.h"
|
||||
#include "facade/cmd_arg_parser.h"
|
||||
#include "facade/op_status.h"
|
||||
#include "server/acl/acl_commands_def.h"
|
||||
|
@ -62,29 +61,6 @@ inline void Evaluate(const json::Path& expr, const JsonType& obj, ExprCallback c
|
|||
});
|
||||
}
|
||||
|
||||
class JsonPathDriver : public json::Driver {
|
||||
public:
|
||||
string msg;
|
||||
void Error(const json::location& l, const std::string& msg) final {
|
||||
this->msg = absl::StrCat("Error: ", msg);
|
||||
}
|
||||
};
|
||||
|
||||
io::Result<json::Path, string> JsonPathV2Parse(string_view path) {
|
||||
if (path.size() > 8_KB)
|
||||
return nonstd::make_unexpected("Path too long");
|
||||
JsonPathDriver driver;
|
||||
json::Parser parser(&driver);
|
||||
|
||||
driver.SetInput(string(path));
|
||||
int res = parser();
|
||||
if (res != 0) {
|
||||
return nonstd::make_unexpected(driver.msg);
|
||||
}
|
||||
|
||||
return driver.TakePath();
|
||||
}
|
||||
|
||||
inline OpStatus JsonReplaceVerifyNoOp(JsonType&) {
|
||||
return OpStatus::OK;
|
||||
}
|
||||
|
@ -1206,7 +1182,7 @@ OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
|
|||
|
||||
io::Result<JsonPathV2, string> ParsePathV2(string_view path) {
|
||||
if (absl::GetFlag(FLAGS_jsonpathv2)) {
|
||||
return JsonPathV2Parse(path);
|
||||
return json::ParsePath(path);
|
||||
}
|
||||
io::Result<JsonExpression> expr_result = ParseJsonPath(path);
|
||||
if (!expr_result) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue