MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / jsonParse

Function jsonParse

eval/CIPO_evaluation/common/gason.cpp:158–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158int jsonParse(char *s, char **endptr, JsonValue *value, JsonAllocator &allocator) {
159 JsonNode *tails[JSON_STACK_SIZE];
160 JsonTag tags[JSON_STACK_SIZE];
161 char *keys[JSON_STACK_SIZE];
162 JsonValue o;
163 int pos = -1;
164 bool separator = true;
165 JsonNode *node;
166 *endptr = s;
167
168 while (*s) {
169 while (isspace(*s)) {
170 ++s;
171 if (!*s) break;
172 }
173 *endptr = s++;
174 switch (**endptr) {
175 case '-':
176 if (!isdigit(*s) && *s != '.') {
177 *endptr = s;
178 return JSON_BAD_NUMBER;
179 }
180 case '0':
181 case '1':
182 case '2':
183 case '3':
184 case '4':
185 case '5':
186 case '6':
187 case '7':
188 case '8':
189 case '9':
190 o = JsonValue(string2double(*endptr, &s));
191 if (!isdelim(*s)) {
192 *endptr = s;
193 return JSON_BAD_NUMBER;
194 }
195 break;
196 case '"':
197 o = JsonValue(JSON_STRING, s);
198 for (char *it = s; *s; ++it, ++s) {
199 int c = *it = *s;
200 if (c == '\\') {
201 c = *++s;
202 switch (c) {
203 case '\\':
204 case '"':
205 case '/':
206 *it = c;
207 break;
208 case 'b':
209 *it = '\b';
210 break;
211 case 'f':
212 *it = '\f';
213 break;
214 case 'n':
215 *it = '\n';

Callers

nothing calls this directly

Calls 10

isspaceFunction · 0.85
isdigitFunction · 0.85
JsonValueFunction · 0.85
string2doubleFunction · 0.85
isdelimFunction · 0.85
isxdigitFunction · 0.85
char2intFunction · 0.85
listToValueFunction · 0.85
insertAfterFunction · 0.85
allocateMethod · 0.80

Tested by

no test coverage detected