MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / readObject

Method readObject

edrav2/eprj/jsoncpp/src/lib_json/json_reader.cpp:455–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455bool Reader::readObject(Token& token) {
456 Token tokenName;
457 JSONCPP_STRING name;
458 Value init(objectValue);
459 currentValue().swapPayload(init);
460 currentValue().setOffsetStart(token.start_ - begin_);
461 while (readToken(tokenName)) {
462 bool initialTokenOk = true;
463 while (tokenName.type_ == tokenComment && initialTokenOk)
464 initialTokenOk = readToken(tokenName);
465 if (!initialTokenOk)
466 break;
467 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
468 return true;
469 name.clear();
470 if (tokenName.type_ == tokenString) {
471 if (!decodeString(tokenName, name))
472 return recoverFromError(tokenObjectEnd);
473 } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
474 Value numberName;
475 if (!decodeNumber(tokenName, numberName))
476 return recoverFromError(tokenObjectEnd);
477 name = JSONCPP_STRING(numberName.asCString());
478 } else {
479 break;
480 }
481
482 Token colon;
483 if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
484 return addErrorAndRecover("Missing ':' after object member name", colon,
485 tokenObjectEnd);
486 }
487 Value& value = currentValue()[name];
488 nodes_.push(&value);
489 bool ok = readValue();
490 nodes_.pop();
491 if (!ok) // error already set
492 return recoverFromError(tokenObjectEnd);
493
494 Token comma;
495 if (!readToken(comma) ||
496 (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
497 comma.type_ != tokenComment)) {
498 return addErrorAndRecover("Missing ',' or '}' in object declaration",
499 comma, tokenObjectEnd);
500 }
501 bool finalizeTokenOk = true;
502 while (comma.type_ == tokenComment && finalizeTokenOk)
503 finalizeTokenOk = readToken(comma);
504 if (comma.type_ == tokenObjectEnd)
505 return true;
506 }
507 return addErrorAndRecover("Missing '}' or object member name", tokenName,
508 tokenObjectEnd);
509}
510
511bool Reader::readArray(Token& token) {
512 Value init(arrayValue);

Callers

nothing calls this directly

Calls 11

throwRuntimeErrorFunction · 0.85
swapPayloadMethod · 0.80
setOffsetStartMethod · 0.80
asCStringMethod · 0.80
asStringMethod · 0.80
isMemberMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected