-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Feat](json) Support json_search function in 2.0 #40962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,6 +340,22 @@ struct leg_info { | |
|
|
||
| ///type: 0 is member 1 is array | ||
| unsigned int type; | ||
|
|
||
| bool to_string(std::string* str) const { | ||
| if (type == MEMBER_CODE) { | ||
| str->push_back(BEGIN_MEMBER); | ||
| str->append(leg_ptr, leg_len); | ||
| return true; | ||
| } else if (type == ARRAY_CODE) { | ||
| str->push_back(BEGIN_ARRAY); | ||
| std::string int_str = std::to_string(array_index); | ||
| str->append(int_str); | ||
| str->push_back(END_ARRAY); | ||
| return true; | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| class JsonbPath { | ||
|
|
@@ -357,6 +373,19 @@ class JsonbPath { | |
| leg_vector.emplace_back(leg.release()); | ||
| } | ||
|
|
||
| void pop_leg_from_leg_vector() { leg_vector.pop_back(); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error] void pop_leg_from_leg_vector() { leg_vector.pop_back(); }
^ |
||
|
|
||
| bool to_string(std::string* res) const { | ||
| res->push_back(SCOPE); | ||
| for (const auto& leg : leg_vector) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error] for (const auto& leg : leg_vector) {
^ |
||
| auto valid = leg->to_string(res); | ||
| if (!valid) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| size_t get_leg_vector_size() { return leg_vector.size(); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error] size_t get_leg_vector_size() { return leg_vector.size(); }
^ |
||
|
|
||
| leg_info* get_leg_from_leg_vector(size_t i) { return leg_vector[i].get(); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error] leg_info* get_leg_from_leg_vector(size_t i) { return leg_vector[i].get(); }
^ |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]
leg_vector.emplace_back(leg.release()); ^