SYS-REQ-116
(wanted string)
| 405 | |
| 406 | // SYS-REQ-116 |
| 407 | func (rp *ReaderParser) readObjectKey(wanted string) (bool, error) { |
| 408 | b, err := rp.peekByte(false) |
| 409 | if err != nil { |
| 410 | return false, err |
| 411 | } |
| 412 | if b != '"' && !(b == '\'' && rp.config.AllowSingleQuotes) { |
| 413 | return false, MalformedJsonError |
| 414 | } |
| 415 | |
| 416 | // The parent prefix is no longer needed. Discarding it before retaining the |
| 417 | // key ensures that an arbitrarily late key does not grow the window. |
| 418 | rp.discardConsumed() |
| 419 | start := rp.pos |
| 420 | if err := rp.scanString(true); err != nil { |
| 421 | return false, err |
| 422 | } |
| 423 | token := rp.buf[start:rp.pos] |
| 424 | body := token[1 : len(token)-1] |
| 425 | if bytes.IndexByte(body, '\\') == -1 { |
| 426 | return string(body) == wanted, nil |
| 427 | } |
| 428 | |
| 429 | var stackbuf [unescapeStackBufSize]byte |
| 430 | unescaped, err := unescapeConfig(rp.config, body, stackbuf[:]) |
| 431 | if err != nil { |
| 432 | return false, err |
| 433 | } |
| 434 | return string(unescaped) == wanted, nil |
| 435 | } |
| 436 | |
| 437 | // SYS-REQ-116 |
| 438 | func (rp *ReaderParser) captureValue() ([]byte, error) { |
no test coverage detected