MCPcopy Create free account
hub / github.com/buger/jsonparser / internalGet

Function internalGet

parser.go:1499–1524  ·  view source on GitHub ↗

SYS-REQ-001

(data []byte, keys ...string)

Source from the content-addressed store, hash-verified

1497
1498// SYS-REQ-001
1499func internalGet(data []byte, keys ...string) (value []byte, dataType ValueType, offset, endOffset int, err error) {
1500 if len(keys) > 0 {
1501 if offset = searchKeys(data, keys...); offset == -1 {
1502 return nil, NotExist, -1, -1, KeyPathNotFoundError
1503 }
1504 }
1505
1506 // Go to closest value
1507 nO := nextToken(data[offset:])
1508 if nO == -1 {
1509 return nil, NotExist, offset, -1, MalformedJsonError
1510 }
1511
1512 offset += nO
1513 value, dataType, endOffset, err = getType(data, offset)
1514 if err != nil {
1515 return value, dataType, offset, endOffset, err
1516 }
1517
1518 // Strip quotes from string values
1519 if dataType == String {
1520 value = value[1 : len(value)-1]
1521 }
1522
1523 return value[:len(value):len(value)], dataType, offset, endOffset, nil
1524}
1525
1526// SYS-REQ-006, SYS-REQ-028, SYS-REQ-029, SYS-REQ-052, SYS-REQ-053, SYS-REQ-055, SYS-REQ-083
1527// ArrayEach is used when iterating arrays, accepts a callback function with the same return arguments as `Get`.

Callers 5

DeleteFoundFunction · 0.85
SetFunction · 0.85
GetFunction · 0.85
GetUint64Function · 0.85

Calls 3

searchKeysFunction · 0.85
nextTokenFunction · 0.85
getTypeFunction · 0.85

Tested by 1