Consolix
Loading...
Searching...
No Matches
JSON Utilities

JSON Utilities

This module provides functions for processing JSON strings. It supports:

  • Removing comments from JSON strings.
  • Handling JSON configurations with comments.

Key Functions:

  • strip_json_comments: Removes comments from a JSON string.
  • check_escaped: Checks if a character is escaped (used internally by strip_json_comments).

Example:

int main() {
std::string raw_json = R"({
"key": "value", // This is a comment
/* Another comment */
"key2": "value2"
})";
std::string clean_json = consolix::strip_json_comments(raw_json);
std::cout << "Clean JSON: " << clean_json << std::endl;
return 0;
}
Utilities for working with JSON strings, including removing comments.
std::string strip_json_comments(const std::string &json_string, bool with_whitespace=false, bool preserve_newlines=true)
Removes comments from a JSON string.