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

Function internalGetConfig

parser.go:1575–1600  ·  view source on GitHub ↗

SYS-REQ-115

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

Source from the content-addressed store, hash-verified

1573
1574// SYS-REQ-115
1575func internalGetConfig(config Config, data []byte, keys ...string) (value []byte, dataType ValueType, offset, endOffset int, err error) {
1576 if len(keys) > 0 {
1577 if offset = searchKeysConfig(config, data, keys...); offset == -1 {
1578 return nil, NotExist, -1, -1, KeyPathNotFoundError
1579 }
1580 }
1581
1582 // Go to closest value
1583 nO := nextTokenConfig(config, data[offset:])
1584 if nO == -1 {
1585 return nil, NotExist, offset, -1, MalformedJsonError
1586 }
1587
1588 offset += nO
1589 value, dataType, endOffset, err = getTypeConfig(config, data, offset)
1590 if err != nil {
1591 return value, dataType, offset, endOffset, err
1592 }
1593
1594 // Strip quotes from string values
1595 if dataType == String {
1596 value = value[1 : len(value)-1]
1597 }
1598
1599 return value[:len(value):len(value)], dataType, offset, endOffset, nil
1600}
1601
1602// SYS-REQ-006, SYS-REQ-028, SYS-REQ-029, SYS-REQ-052, SYS-REQ-053, SYS-REQ-055, SYS-REQ-083
1603// ArrayEach is used when iterating arrays, accepts a callback function with the same return arguments as `Get`.

Callers 4

deleteFoundConfigFunction · 0.85
setConfigFunction · 0.85
internalGetFunction · 0.85
GetMethod · 0.85

Calls 3

searchKeysConfigFunction · 0.85
nextTokenConfigFunction · 0.85
getTypeConfigFunction · 0.85

Tested by

no test coverage detected