MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ParseArray

Method ParseArray

LibLemon/src/json.cpp:255–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253 }
254
255 JSONValue JSONParser::ParseArray(){
256 if(!EatOne('[')){
257 #ifdef LIBLEMON_DEBUG_JSON
258 printf("Expected [, line %d.\n", line);
259 #endif
260 return JSONValue();
261 }
262
263 std::vector<JSONValue> values;
264 while(!End()){
265 EatWhitespace();
266
267 JSONValue v;
268 if(ParseValue(v)){
269 return JSONValue(); // Error parsing value
270 }
271
272 values.push_back(v);
273
274 EatWhitespace();
275
276 char c = Peek();
277 if(c != ','){ // If there is a comma keep going, otherwise break
278 break;
279 } else {
280 Eat();
281 }
282 }
283
284 EatWhitespace();
285 if(!EatOne(']')){
286 #ifdef LIBLEMON_DEBUG_JSON
287 printf("Expected ], line %d.\n", line);
288 #endif
289 return JSONValue();
290 }
291
292 return JSONValue(values);
293 }
294}

Callers

nothing calls this directly

Calls 1

JSONValueClass · 0.85

Tested by

no test coverage detected