PragmaTwice commented on code in PR #1850:
URL: https://github.com/apache/kvrocks/pull/1850#discussion_r1368434621
##########
src/types/json.h:
##########
@@ -172,6 +172,34 @@ struct JsonValue {
return Status::OK();
}
+ Status Clear(std::string_view path, int *result) {
+ try {
+ int cleared_count = 0;
+ jsoncons::jsonpath::json_replace(value, path,
+ [&cleared_count](const std::string &
+ /*path*/,
+ jsoncons::json &val) {
+ bool is_array = val.is_array() &&
!val.empty();
+ bool is_object = val.is_object() &&
!val.empty();
+ bool is_number = val.is_number() &&
val.as<double>() != 0;
+
+ if (!is_number && !is_array &&
!is_object) {
+ return;
+ }
+
+ if (is_array) val =
jsoncons::json::array();
+ if (is_object) val =
jsoncons::json::object();
+ if (is_number) val = 0;
Review Comment:
```suggestion
if (is_array) val =
jsoncons::json::array();
else if (is_object) val =
jsoncons::json::object();
else if (is_number) val = 0;
else return;
```
--
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]