guojidan commented on code in PR #1841:
URL: https://github.com/apache/kvrocks/pull/1841#discussion_r1367024662


##########
src/types/json.h:
##########
@@ -65,6 +66,29 @@ struct JsonValue {
     return Status::OK();
   }
 
+  Status Append(std::string_view path, const std::string &append_value, 
std::vector<uint64_t> &append_cnt) {
+    try {
+      auto append_trimmed = util::Trim(append_value, "\"");
+      jsoncons::jsonpath::json_replace(value, path, [&append_trimmed, 
&append_cnt](const std::string & /*path*/, jsoncons::json &origin) {
+        uint64_t len = 0;
+        if (origin.is_string()) {
+          auto origin_str = origin.to_string();
+          // need trim "
+          auto origin_trimmed = util::Trim(origin_str, "\"");
+          len = origin_trimmed.length() + append_trimmed.length();
+          std::string new_value;
+          
new_value.append("\"").append(origin_trimmed).append(append_trimmed).append("\"");
+          origin = jsoncons::json::parse(new_value);
+        }
+        append_cnt.push_back(len);

Review Comment:
   `len` initialization 0,so there logic is right



##########
src/types/json.h:
##########
@@ -65,6 +66,29 @@ struct JsonValue {
     return Status::OK();
   }
 
+  Status Append(std::string_view path, const std::string &append_value, 
std::vector<uint64_t> &append_cnt) {
+    try {
+      auto append_trimmed = util::Trim(append_value, "\"");
+      jsoncons::jsonpath::json_replace(value, path, [&append_trimmed, 
&append_cnt](const std::string & /*path*/, jsoncons::json &origin) {
+        uint64_t len = 0;
+        if (origin.is_string()) {
+          auto origin_str = origin.to_string();
+          // need trim "
+          auto origin_trimmed = util::Trim(origin_str, "\"");
+          len = origin_trimmed.length() + append_trimmed.length();
+          std::string new_value;
+          
new_value.append("\"").append(origin_trimmed).append(append_trimmed).append("\"");
+          origin = jsoncons::json::parse(new_value);
+        }
+        append_cnt.push_back(len);

Review Comment:
   `len` initialization 0,so there logic is right



-- 
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]

Reply via email to