nhancdt2602 opened a new pull request, #3549:
URL: https://github.com/apache/kvrocks/pull/3549

   ## Summary
   
   Add an optional `FORMAT (TXT | JSON)` option to the `INFO` command:
   
   ```
   INFO [<section> ...] [FORMAT (TXT | JSON)]
   ```
   
   - `FORMAT TXT` (the default) keeps the existing Redis-compatible text output.
   - `FORMAT JSON` emits the same data as a JSON object keyed by section.
   
   ```
   127.0.0.1:6666> INFO server FORMAT JSON
   {"Server":{"version":"unstable","tcp_port":6666,"process_id":123,...}}
   ```
   
   Closes #2302.
   
   ## Changes
   
   - `CommandInfo`: parse the optional `FORMAT` keyword, separating it from 
section names.
   - `InfoEntry`: store each value as a typed `std::variant`; `GetInfo` 
serializes to text or JSON.
   - Add `TestInfoFormat` integration tests.
   
   ## Implementation Note
   
   Each `INFO` value carries its original type in the `InfoEntry` variant
   `std::variant<std::string, int64_t, uint64_t, double, bool>`, captured in 
the constructors, so
   the collectors stay unchanged and each format renders the value at 
serialization time:
   
   - **Text**: booleans as `0/1`, numbers via `std::to_string`, strings 
verbatim — identical to the
     previous output.
   - **JSON**: native types — numbers unquoted, booleans as `true/false`, 
strings quoted.
   
   Floating-point values are canonicalized through their text form so the JSON 
number matches the
   text and carries no float-to-double widening noise. The `FORMAT` keyword is 
case-insensitive;
   an unknown or missing value returns `syntax error`.
   


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