MCPcopy Index your code
hub / github.com/clips/pattern / JSONArray

Function JSONArray

pattern/web/json/decoder.py:276–310  ·  view source on GitHub ↗
((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR)

Source from the content-addressed store, hash-verified

274 return pairs, end
275
276def JSONArray((s, end), scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
277 values = []
278 nextchar = s[end:end + 1]
279 if nextchar in _ws:
280 end = _w(s, end + 1).end()
281 nextchar = s[end:end + 1]
282 # Look-ahead for trivial empty array
283 if nextchar == ']':
284 return values, end + 1
285 _append = values.append
286 while True:
287 try:
288 value, end = scan_once(s, end)
289 except StopIteration:
290 raise JSONDecodeError("Expecting object", s, end)
291 _append(value)
292 nextchar = s[end:end + 1]
293 if nextchar in _ws:
294 end = _w(s, end + 1).end()
295 nextchar = s[end:end + 1]
296 end += 1
297 if nextchar == ']':
298 break
299 elif nextchar != ',':
300 raise JSONDecodeError("Expecting ',' delimiter", s, end)
301
302 try:
303 if s[end] in _ws:
304 end += 1
305 if s[end] in _ws:
306 end = _w(s, end + 1).end()
307 except IndexError:
308 pass
309
310 return values, end
311
312class JSONDecoder(object):
313 """Simple JSON <http://json.org> decoder

Callers

nothing calls this directly

Calls 2

scan_onceFunction · 0.85
JSONDecodeErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…