diff Lib/json/decoder.py @ 69313:d58c63ff5bb2 2.7

#9233: Fix json.loads({}) to return a dict (instead of a list), when _json is not available.
author Ezio Melotti
date Wed, 13 Apr 2011 05:37:29 +0300
parents 9347b0a85caf
children 5b0fecd2eba0
line wrap: on
line diff
--- a/Lib/json/decoder.py	Tue Apr 12 18:54:46 2011 -0700
+++ b/Lib/json/decoder.py	Wed Apr 13 05:37:29 2011 +0300
@@ -161,6 +161,12 @@
             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))