mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
#9233: Fix json.loads({}) to return a dict (instead of a list), when _json is not available.
This commit is contained in:
parent
42368f9b0c
commit
d210aa1ad9
2 changed files with 11 additions and 0 deletions
|
@ -161,6 +161,12 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
|
|||
nextchar = s[end:end + 1]
|
||||
# Trivial empty object
|
||||
if nextchar == '}':
|
||||
if object_pairs_hook is not None:
|
||||
result = object_pairs_hook(pairs)
|
||||
return result, end
|
||||
pairs = {}
|
||||
if object_hook is not None:
|
||||
pairs = object_hook(pairs)
|
||||
return pairs, end + 1
|
||||
elif nextchar != '"':
|
||||
raise ValueError(errmsg("Expecting property name", s, end))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue