MCPcopy Create free account
hub / github.com/crownengine/crown / parse_object

Function parse_object

src/core/json/sjson.cpp:496–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494 }
495
496 void parse_object(JsonObject &obj, const char *json)
497 {
498 if (json == NULL) {
499 fatal("json is NULL");
500 return;
501 }
502
503 if (*json == '{') {
504 json = skip_spaces(++json);
505 if (json == NULL)
506 return;
507
508 if (*json == '}') {
509 obj._end = json + 1;
510 return;
511 }
512
513 while (*json) {
514 const char *key_begin = *json == '"' ? (json + 1) : json;
515
516 TempAllocator256 ta;
517 DynamicString key(ta);
518 json = parse_key(json, key);
519 if (json == NULL)
520 return;
521
522 StringView fs_key(key_begin, key.length());
523
524 json = skip_spaces(json);
525 if (json == NULL)
526 return;
527 NEXT_OR_RETURN(json, (*json == '=') ? '=' : ':', /*void*/);
528 json = skip_spaces(json);
529 if (json == NULL)
530 return;
531
532 hash_map::set(obj._map, fs_key, json);
533
534 json = skip_value(json);
535 if (json == NULL)
536 return;
537
538 json = skip_spaces(json);
539 if (json == NULL)
540 return;
541
542 if (*json == '}') {
543 obj._end = json + 1;
544 return;
545 }
546
547 json = skip_spaces(json);
548 if (json == NULL)
549 return;
550 }
551 }
552
553 fatal("Bad object");

Callers 1

parseFunction · 0.70

Calls 6

skip_spacesFunction · 0.85
parse_keyFunction · 0.85
setClass · 0.85
fatalFunction · 0.70
skip_valueFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected