jackyyyyyssss commented on code in PR #2323:
URL: https://github.com/apache/kvrocks/pull/2323#discussion_r1609215770


##########
src/types/json.h:
##########
@@ -217,6 +217,42 @@ struct JsonValue {
     return results;
   }
 
+  StatusOr<std::vector<std::string>> GetBytes(std::string_view path, 
JsonStorageFormat format,
+                                              int max_nesting_depth = 
std::numeric_limits<int>::max()) const {
+    std::vector<std::string> results;
+    try {
+      jsoncons::jsonpath::json_query(value, path, [&](const std::string & 
/*path*/, const jsoncons::json &origin) {
+        if (!origin.empty()) {
+          Status s;
+          std::string buffer;
+          std::error_code ec;
+          if (format == JsonStorageFormat::JSON) {
+            jsoncons::json_options options;
+            options.max_nesting_depth(max_nesting_depth);
+            jsoncons::compact_json_string_encoder encoder{buffer, options};
+            origin.dump(encoder, ec);
+          } else if (format == JsonStorageFormat::CBOR) {
+            jsoncons::cbor::cbor_options options;
+            options.max_nesting_depth(max_nesting_depth);
+            
jsoncons::cbor::basic_cbor_encoder<jsoncons::string_sink<std::string>> 
encoder{buffer, options};
+            origin.dump(encoder, ec);
+          }

Review Comment:
   Dump and DumpCBOR cannot meet the JSON requirements for passing values. Do 
you suggest modifying this method to meet these requirements



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