Index: Lib/json/decoder.py =================================================================== --- Lib/json/decoder.py (revision 70015) +++ Lib/json/decoder.py (working copy) @@ -160,13 +160,13 @@ def JSONObject(match, context, _w=WHITESPACE.match): - pairs = {} + pairs = [] s = match.string end = _w(s, match.end()).end() nextchar = s[end:end + 1] # Trivial empty object if nextchar == '}': - return pairs, end + 1 + return {}, end + 1 if nextchar != '"': raise ValueError(errmsg("Expecting property name", s, end)) end += 1 @@ -183,7 +183,7 @@ value, end = iterscan(s, idx=end, context=context).next() except StopIteration: raise ValueError(errmsg("Expecting object", s, end)) - pairs[key] = value + pairs.append((key, value)) end = _w(s, end).end() nextchar = s[end:end + 1] end += 1 @@ -196,7 +196,12 @@ end += 1 if nextchar != '"': raise ValueError(errmsg("Expecting property name", s, end - 1)) - object_hook = getattr(context, 'object_hook', None) + object_pair_hook = getattr(context, 'object_pair_hook', None) + if object_pair_hook is not None: + pairs = object_pair_hook(pairs) + else: + pairs = dict(pairs) + object_hook = getattr(context, 'object_hook', None) if object_hook is not None: pairs = object_hook(pairs) return pairs, end