(idx int)
| 396 | } |
| 397 | |
| 398 | func (j *jsonEncoded) FetchValIdx(idx int) (JSON, error) { |
| 399 | if dec := j.alreadyDecoded(); dec != nil { |
| 400 | return dec.FetchValIdx(idx) |
| 401 | } |
| 402 | |
| 403 | if j.Type() == ArrayJSONType { |
| 404 | if idx < 0 { |
| 405 | idx = j.containerLen + idx |
| 406 | } |
| 407 | if idx < 0 || idx >= j.containerLen { |
| 408 | return nil, nil |
| 409 | } |
| 410 | |
| 411 | // We need to find the bounds for a given index, but this is nontrivial, |
| 412 | // since some headers store an offset and some store a length. |
| 413 | |
| 414 | begin, end, entry, err := j.getNthEntryBounds(idx) |
| 415 | if err != nil { |
| 416 | return nil, err |
| 417 | } |
| 418 | |
| 419 | return newEncoded(entry, j.arrayGetDataRange(begin, end)) |
| 420 | } |
| 421 | return nil, nil |
| 422 | } |
| 423 | |
| 424 | func (j *jsonEncoded) FetchValKey(key string) (JSON, error) { |
| 425 | if dec := j.alreadyDecoded(); dec != nil { |
no test coverage detected