mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
chore: Support json paths without root selector (#2747)
* chore: Support json paths without root selector --------- Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
parent
2d246adbbb
commit
1ec603e568
2 changed files with 14 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "server/json_family.h"
|
||||
|
||||
#include <absl/strings/match.h>
|
||||
#include <absl/strings/str_cat.h>
|
||||
#include <absl/strings/str_join.h>
|
||||
#include <absl/strings/str_split.h>
|
||||
|
||||
|
@ -1295,6 +1296,13 @@ OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
|
|||
}
|
||||
|
||||
io::Result<JsonPathV2, string> ParsePathV2(string_view path) {
|
||||
// We expect all valid paths to start with the root selector, otherwise prepend it
|
||||
string tmp_buf;
|
||||
if (!path.empty() && path.front() != '$') {
|
||||
tmp_buf = absl::StrCat("$", path.front() != '.' ? "." : "", path);
|
||||
path = tmp_buf;
|
||||
}
|
||||
|
||||
if (absl::GetFlag(FLAGS_jsonpathv2)) {
|
||||
return json::ParsePath(path);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue