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

Function blockEndConfig

parser.go:374–405  ·  view source on GitHub ↗

SYS-REQ-115

(config Config, data []byte, openSym byte, closeSym byte)

Source from the content-addressed store, hash-verified

372
373// SYS-REQ-115
374func blockEndConfig(config Config, data []byte, openSym byte, closeSym byte) int {
375 level := 0
376 i := 0
377 ln := len(data)
378
379 for i < ln {
380 switch data[i] {
381 case '"', '\'': // If inside a configured string, skip it
382 quote := data[i]
383 if quote == '\'' && !config.AllowSingleQuotes {
384 break
385 }
386 se, _ := stringEndConfig(config, data[i+1:], quote)
387 if se == -1 {
388 return -1
389 }
390 i += se
391 case openSym: // If open symbol, increase level
392 level++
393 case closeSym: // If close symbol, increase level
394 level--
395
396 // If we have returned to the original level, we're done
397 if level == 0 {
398 return i + 1
399 }
400 }
401 i++
402 }
403
404 return -1
405}
406
407// SYS-REQ-001, SYS-REQ-020, SYS-REQ-021, SYS-REQ-022, SYS-REQ-023, SYS-REQ-047, SYS-REQ-111
408func searchKeys(data []byte, keys ...string) int {

Callers 5

findKeyStartConfigFunction · 0.85
blockEndFunction · 0.85
searchKeysConfigFunction · 0.85
setConfigFunction · 0.85
getTypeConfigFunction · 0.85

Calls 1

stringEndConfigFunction · 0.85

Tested by

no test coverage detected