MCPcopy
hub / github.com/buger/jsonparser / internalGet

Function internalGet

parser.go:998–1023  ·  view source on GitHub ↗

SYS-REQ-001

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

Source from the content-addressed store, hash-verified

996
997// SYS-REQ-001
998func internalGet(data []byte, keys ...string) (value []byte, dataType ValueType, offset, endOffset int, err error) {
999 if len(keys) > 0 {
1000 if offset = searchKeys(data, keys...); offset == -1 {
1001 return nil, NotExist, -1, -1, KeyPathNotFoundError
1002 }
1003 }
1004
1005 // Go to closest value
1006 nO := nextToken(data[offset:])
1007 if nO == -1 {
1008 return nil, NotExist, offset, -1, MalformedJsonError
1009 }
1010
1011 offset += nO
1012 value, dataType, endOffset, err = getType(data, offset)
1013 if err != nil {
1014 return value, dataType, offset, endOffset, err
1015 }
1016
1017 // Strip quotes from string values
1018 if dataType == String {
1019 value = value[1 : len(value)-1]
1020 }
1021
1022 return value[:len(value):len(value)], dataType, offset, endOffset, nil
1023}
1024
1025// SYS-REQ-006, SYS-REQ-028, SYS-REQ-029, SYS-REQ-052, SYS-REQ-053, SYS-REQ-055, SYS-REQ-083
1026// ArrayEach is used when iterating arrays, accepts a callback function with the same return arguments as `Get`.

Callers 3

DeleteFunction · 0.85
SetFunction · 0.85
GetFunction · 0.85

Calls 3

searchKeysFunction · 0.85
nextTokenFunction · 0.85
getTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…