PragmaTwice commented on code in PR #1829:
URL: https://github.com/apache/kvrocks/pull/1829#discussion_r1367215984
##########
src/types/json.h:
##########
@@ -23,10 +23,51 @@
#include <jsoncons/json.hpp>
#include <jsoncons/json_error.hpp>
#include <jsoncons_ext/jsonpath/json_query.hpp>
+#include <jsoncons_ext/jsonpath/jsonpath_error.hpp>
-#include "jsoncons_ext/jsonpath/jsonpath_error.hpp"
#include "status.h"
+class JsonPath {
+ public:
+ using JsonType = jsoncons::json;
+ using JsonPathExpression = jsoncons::jsonpath::jsonpath_expression<JsonType,
const JsonType &>;
+
+ static constexpr std::string_view ROOT_PATH = "$";
+
+ static StatusOr<JsonPath> BuildJsonPath(std::string_view path);
+
+ bool IsLegacy() const noexcept { return is_legacy_; }
+
+ std::string_view Path() const { return path_; }
+
+ bool IsRootPath() const { return Path() == ROOT_PATH; }
+
+ JsonType EvalJsonQuery(const JsonType &json_value) const {
+ return expression_.evaluate(const_cast<JsonType &>(json_value));
+ }
Review Comment:
Could it return multiple query result? e.g. query `$..a` from
`{"a":{"a":1}}`, we'll get `{"a":1}` and `1`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]