Index: Lib/json/decoder.py =================================================================== --- Lib/json/decoder.py (revision 70157) +++ Lib/json/decoder.py (working copy) @@ -3,6 +3,7 @@ import re import sys +from collections import OrderedDict from json.scanner import Scanner, pattern try: @@ -16,6 +17,10 @@ NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf') +class Dict(OrderedDict): + 'Ordered substitute for dict with normal dict.__repr__ format' + def __repr__(self): + return '{' + ', '.join(['%r: %r' % item for item in self.items()]) + '}' def linecol(doc, pos): if isinstance(doc, bytes): @@ -164,7 +169,7 @@ def JSONObject(match, context, _w=WHITESPACE.match): - pairs = {} + pairs = Dict() s = match.string end = _w(s, match.end()).end() nextchar = s[end:end + 1]