(idx int)
| 382 | } |
| 383 | |
| 384 | func (j *jsonEncoded) FetchValIdx(idx int) (JSON, error) { |
| 385 | if dec := j.alreadyDecoded(); dec != nil { |
| 386 | return dec.FetchValIdx(idx) |
| 387 | } |
| 388 | |
| 389 | if j.Type() == ArrayJSONType { |
| 390 | if idx < 0 { |
| 391 | idx = j.containerLen + idx |
| 392 | } |
| 393 | if idx < 0 || idx >= j.containerLen { |
| 394 | return nil, nil |
| 395 | } |
| 396 | |
| 397 | // We need to find the bounds for a given index, but this is nontrivial, |
| 398 | // since some headers store an offset and some store a length. |
| 399 | |
| 400 | begin, end, entry, err := j.getNthEntryBounds(idx) |
| 401 | if err != nil { |
| 402 | return nil, err |
| 403 | } |
| 404 | |
| 405 | return newEncoded(entry, j.arrayGetDataRange(begin, end)) |
| 406 | } |
| 407 | return nil, nil |
| 408 | } |
| 409 | |
| 410 | func (j *jsonEncoded) FetchValKey(key string) (JSON, error) { |
| 411 | if dec := j.alreadyDecoded(); dec != nil { |
no test coverage detected