Try OrderedDict
from the standard library collections
:
>>> import json
>>> from collections import OrderedDict
>>> values = OrderedDict([('profile','testprofile'),
('format', 'RSA_RC4_Sealed'),
('enc_key', '...'),
('request', '...')])
>>> json.dumps(values, sort_keys=False)
'{"profile": "testprofile", "format": "RSA_RC4_Sealed", "enc_key": "...", "request": "..."}'
Unfortunately this feature is New in version 2.7
for collections