MCPcopy Index your code
hub / github.com/python/cpython / JSONArray

Function JSONArray

Lib/json/decoder.py:221–263  ·  view source on GitHub ↗
(s_and_end, scan_once, array_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR)

Source from the content-addressed store, hash-verified

219 return pairs, end
220
221def JSONArray(s_and_end, scan_once, array_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
222 s, end = s_and_end
223 values = []
224 nextchar = s[end:end + 1]
225 if nextchar in _ws:
226 end = _w(s, end + 1).end()
227 nextchar = s[end:end + 1]
228 # Look-ahead for trivial empty array
229 if nextchar == ']':
230 if array_hook is not None:
231 values = array_hook(values)
232 return values, end + 1
233 _append = values.append
234 while True:
235 try:
236 value, end = scan_once(s, end)
237 except StopIteration as err:
238 raise JSONDecodeError("Expecting value", s, err.value) from None
239 _append(value)
240 nextchar = s[end:end + 1]
241 if nextchar in _ws:
242 end = _w(s, end + 1).end()
243 nextchar = s[end:end + 1]
244 end += 1
245 if nextchar == ']':
246 break
247 elif nextchar != ',':
248 raise JSONDecodeError("Expecting ',' delimiter", s, end - 1)
249 comma_idx = end - 1
250 try:
251 if s[end] in _ws:
252 end += 1
253 if s[end] in _ws:
254 end = _w(s, end + 1).end()
255 nextchar = s[end:end + 1]
256 except IndexError:
257 pass
258 if nextchar == ']':
259 raise JSONDecodeError("Illegal trailing comma before end of array", s, comma_idx)
260
261 if array_hook is not None:
262 values = array_hook(values)
263 return values, end
264
265
266class JSONDecoder(object):

Callers

nothing calls this directly

Calls 4

_wFunction · 0.85
scan_onceFunction · 0.85
JSONDecodeErrorClass · 0.85
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…