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

Function internalGet

parser.go:1259–1284  ·  view source on GitHub ↗

SYS-REQ-001

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

Source from the content-addressed store, hash-verified

1257
1258// SYS-REQ-001
1259func internalGet(data []byte, keys ...string) (value []byte, dataType ValueType, offset, endOffset int, err error) {
1260 if len(keys) > 0 {
1261 if offset = searchKeys(data, keys...); offset == -1 {
1262 return nil, NotExist, -1, -1, KeyPathNotFoundError
1263 }
1264 }
1265
1266 // Go to closest value
1267 nO := nextToken(data[offset:])
1268 if nO == -1 {
1269 return nil, NotExist, offset, -1, MalformedJsonError
1270 }
1271
1272 offset += nO
1273 value, dataType, endOffset, err = getType(data, offset)
1274 if err != nil {
1275 return value, dataType, offset, endOffset, err
1276 }
1277
1278 // Strip quotes from string values
1279 if dataType == String {
1280 value = value[1 : len(value)-1]
1281 }
1282
1283 return value[:len(value):len(value)], dataType, offset, endOffset, nil
1284}
1285
1286// SYS-REQ-006, SYS-REQ-028, SYS-REQ-029, SYS-REQ-052, SYS-REQ-053, SYS-REQ-055, SYS-REQ-083
1287// ArrayEach is used when iterating arrays, accepts a callback function with the same return arguments as `Get`.

Callers 4

DeleteFunction · 0.85
SetFunction · 0.85
GetFunction · 0.85

Calls 3

searchKeysFunction · 0.85
nextTokenFunction · 0.85
getTypeFunction · 0.85

Tested by 1