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

Function internalGetConfig

parser.go:1615–1640  ·  view source on GitHub ↗

SYS-REQ-115

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

Source from the content-addressed store, hash-verified

1613
1614// SYS-REQ-115
1615func internalGetConfig(config Config, data []byte, keys ...string) (value []byte, dataType ValueType, offset, endOffset int, err error) {
1616 if len(keys) > 0 {
1617 if offset = searchKeysConfig(config, data, keys...); offset == -1 {
1618 return nil, NotExist, -1, -1, KeyPathNotFoundError
1619 }
1620 }
1621
1622 // Go to closest value
1623 nO := nextTokenConfig(config, data[offset:])
1624 if nO == -1 {
1625 return nil, NotExist, offset, -1, MalformedJsonError
1626 }
1627
1628 offset += nO
1629 value, dataType, endOffset, err = getTypeConfig(config, data, offset)
1630 if err != nil {
1631 return value, dataType, offset, endOffset, err
1632 }
1633
1634 // Strip quotes from string values
1635 if dataType == String {
1636 value = value[1 : len(value)-1]
1637 }
1638
1639 return value[:len(value):len(value)], dataType, offset, endOffset, nil
1640}
1641
1642// SYS-REQ-006, SYS-REQ-028, SYS-REQ-029, SYS-REQ-052, SYS-REQ-053, SYS-REQ-055, SYS-REQ-083
1643// 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