Consolix
Toggle main menu visibility
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:
#include <
consolix/utils/json_utils.hpp
>
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;
}
json_utils.hpp
Utilities for working with JSON strings, including removing comments.
consolix::strip_json_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.
Definition
json_utils.hpp:38
main
int main()
Definition
test_strip_json_comments.cpp:28
Generated by
1.17.0