MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / convert_cjson

Function convert_cjson

src/framework/io/json.cpp:78–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78std::string strip_jsonc_comments(std::string_view text) {
79 std::string out;
80 out.reserve(text.size());
81 bool in_string = false;
82 bool escaped = false;
83 for (size_t index = 0; index < text.size(); ++index) {
84 const char ch = text[index];
85 if (in_string) {
86 out.push_back(ch);
87 if (escaped) {
88 escaped = false;
89 } else if (ch == '\\') {
90 escaped = true;
91 } else if (ch == '"') {
92 in_string = false;
93 }
94 continue;
95 }
96 if (ch == '"') {
97 in_string = true;
98 out.push_back(ch);
99 continue;
100 }
101 if (ch == '/' && index + 1 < text.size() && text[index + 1] == '/') {
102 while (index < text.size() && text[index] != '\n') {
103 ++index;
104 }
105 if (index < text.size()) {
106 out.push_back('\n');
107 }
108 continue;
109 }
110 out.push_back(ch);
111 }
112 return out;
113}
114
115std::string strip_jsonc_trailing_commas(std::string_view text) {
116 std::string out;
117 out.reserve(text.size());
118 bool in_string = false;
119 bool escaped = false;

Callers 1

parseFunction · 0.85

Calls 8

cJSON_IsNullFunction · 0.85
cJSON_IsBoolFunction · 0.85
cJSON_IsTrueFunction · 0.85
cJSON_IsNumberFunction · 0.85
cJSON_IsStringFunction · 0.85
cJSON_IsArrayFunction · 0.85
cJSON_GetArraySizeFunction · 0.85
cJSON_IsObjectFunction · 0.85

Tested by

no test coverage detected