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

Function blockEndConfig

parser.go:355–386  ·  view source on GitHub ↗

SYS-REQ-115

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

Source from the content-addressed store, hash-verified

353
354// SYS-REQ-115
355func blockEndConfig(config Config, data []byte, openSym byte, closeSym byte) int {
356 level := 0
357 i := 0
358 ln := len(data)
359
360 for i < ln {
361 switch data[i] {
362 case '"', '\'': // If inside a configured string, skip it
363 quote := data[i]
364 if quote == '\'' && !config.AllowSingleQuotes {
365 break
366 }
367 se, _ := stringEndConfig(config, data[i+1:], quote)
368 if se == -1 {
369 return -1
370 }
371 i += se
372 case openSym: // If open symbol, increase level
373 level++
374 case closeSym: // If close symbol, increase level
375 level--
376
377 // If we have returned to the original level, we're done
378 if level == 0 {
379 return i + 1
380 }
381 }
382 i++
383 }
384
385 return -1
386}
387
388// SYS-REQ-001, SYS-REQ-020, SYS-REQ-021, SYS-REQ-022, SYS-REQ-023, SYS-REQ-047, SYS-REQ-111
389func searchKeys(data []byte, keys ...string) int {

Callers 4

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

Calls 1

stringEndConfigFunction · 0.85

Tested by

no test coverage detected