MCPcopy
hub / github.com/buger/jsonparser / blockEnd

Function blockEnd

parser.go:201–228  ·  view source on GitHub ↗

SYS-REQ-046 Find end of the data structure, array or object. For array openSym and closeSym will be '[' and ']', for object '{' and '}'

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

Source from the content-addressed store, hash-verified

199// Find end of the data structure, array or object.
200// For array openSym and closeSym will be '[' and ']', for object '{' and '}'
201func blockEnd(data []byte, openSym byte, closeSym byte) int {
202 level := 0
203 i := 0
204 ln := len(data)
205
206 for i < ln {
207 switch data[i] {
208 case '"': // If inside string, skip it
209 se, _ := stringEnd(data[i+1:])
210 if se == -1 {
211 return -1
212 }
213 i += se
214 case openSym: // If open symbol, increase level
215 level++
216 case closeSym: // If close symbol, increase level
217 level--
218
219 // If we have returned to the original level, we're done
220 if level == 0 {
221 return i + 1
222 }
223 }
224 i++
225 }
226
227 return -1
228}
229
230// SYS-REQ-001, SYS-REQ-020, SYS-REQ-021, SYS-REQ-022, SYS-REQ-023, SYS-REQ-047
231func searchKeys(data []byte, keys ...string) int {

Callers 5

findKeyStartFunction · 0.85
searchKeysFunction · 0.85
EachKeyFunction · 0.85
getTypeFunction · 0.85
TestBlockEndSentinelFunction · 0.85

Calls 1

stringEndFunction · 0.85

Tested by 1

TestBlockEndSentinelFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…