value consumes a JSON value from d.data[d.off-1:], decoding into v, and reads the following byte ahead. If v is invalid, the value is discarded. The first byte of the value has been read already.
(v reflect.Value)
| 361 | // reads the following byte ahead. If v is invalid, the value is discarded. |
| 362 | // The first byte of the value has been read already. |
| 363 | func (d *decodeState) value(v reflect.Value) error { |
| 364 | switch d.opcode { |
| 365 | default: |
| 366 | panic(phasePanicMsg) |
| 367 | |
| 368 | case scanBeginArray: |
| 369 | if v.IsValid() { |
| 370 | if err := d.array(v); err != nil { |
| 371 | return err |
| 372 | } |
| 373 | } else { |
| 374 | d.skip() |
| 375 | } |
| 376 | d.scanNext() |
| 377 | |
| 378 | case scanBeginObject: |
| 379 | if v.IsValid() { |
| 380 | if err := d.object(v); err != nil { |
| 381 | return err |
| 382 | } |
| 383 | } else { |
| 384 | d.skip() |
| 385 | } |
| 386 | d.scanNext() |
| 387 | |
| 388 | case scanBeginLiteral: |
| 389 | // All bytes inside literal return scanContinue op code. |
| 390 | start := d.readIndex() |
| 391 | d.scanWhile(scanContinue) |
| 392 | |
| 393 | if v.IsValid() { |
| 394 | if err := d.literalStore(d.data[start:d.readIndex()], v, false); err != nil { |
| 395 | return err |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | return nil |
| 400 | } |
| 401 | |
| 402 | type unquotedValue struct{} |
| 403 |