MCPcopy Index your code
hub / github.com/RustPython/RustPython / JSONArray

Function JSONArray

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

Source from the content-addressed store, hash-verified

233 return pairs, end
234
235def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
236 s, end = s_and_end
237 values = []
238 nextchar = s[end:end + 1]
239 if nextchar in _ws:
240 end = _w(s, end + 1).end()
241 nextchar = s[end:end + 1]
242 # Look-ahead for trivial empty array
243 if nextchar == ']':
244 return values, end + 1
245 _append = values.append
246 while True:
247 try:
248 value, end = scan_once(s, end)
249 except StopIteration as err:
250 raise JSONDecodeError("Expecting value", s, err.value) from None
251 _append(value)
252 nextchar = s[end:end + 1]
253 if nextchar in _ws:
254 end = _w(s, end + 1).end()
255 nextchar = s[end:end + 1]
256 end += 1
257 if nextchar == ']':
258 break
259 elif nextchar != ',':
260 raise JSONDecodeError("Expecting ',' delimiter", s, end - 1)
261 comma_idx = end - 1
262 try:
263 if s[end] in _ws:
264 end += 1
265 if s[end] in _ws:
266 end = _w(s, end + 1).end()
267 nextchar = s[end:end + 1]
268 except IndexError:
269 pass
270 if nextchar == ']':
271 raise JSONDecodeError("Illegal trailing comma before end of array", s, comma_idx)
272
273 return values, end
274
275
276class JSONDecoder(object):

Callers

nothing calls this directly

Calls 3

scan_onceFunction · 0.85
JSONDecodeErrorClass · 0.85
endMethod · 0.45

Tested by

no test coverage detected