35 const std::string input_file =
"test_input.json";
36 const std::string output_file_base =
"test_output";
39 std::string json_string =
read_file(consolix::resolve_exec_path(input_file));
42 for (
bool with_whitespace : {
false,
true}) {
43 for (
bool preserve_newlines : {
false,
true}) {
48 std::string output_file = output_file_base +
49 (with_whitespace ?
"_whitespace" :
"_no_whitespace") +
50 (preserve_newlines ?
"_preserve_newlines" :
"_no_newlines") +
54 write_file(consolix::resolve_exec_path(output_file), result);
57 std::cout <<
"Processed with "
58 <<
"with_whitespace=" << with_whitespace <<
", "
59 <<
"preserve_newlines=" << preserve_newlines <<
"\n"
60 <<
"Result saved to: " << output_file << std::endl;
64 std::cout <<
"All tests completed successfully!" << std::endl;
66 }
catch (
const std::exception& e) {
67 std::cerr <<
"Error: " << e.what() << std::endl;
*The resulting JSON string may optionally retain whitespace or newlines *where the comments were removed **param json_string The JSON string to process *param with_whitespace If comments are replaced with equivalent whitespace *If comments are removed without leaving whitespace *param preserve_newlines If true and with_whitespace is newline characters *in comments are preserved all characters in the *comments are replaced with whitespace *return A JSON string with comments removed *std::string strip_json_comments(const std::string &json_string, bool with_whitespace=false, bool preserve_newlines=true)