I am using Python 2.6 to load a JSON string. I want to maintain the key order of the string when I load. I tried using the answer here: Can I get JSON to load into an OrderedDict in Python?
and I made sure to import simplejson as json
since I am on Python 2.6, but I am still receiving this error:
TypeError: __init__() got an unexpected keyword argument 'object_pairs_hook'
What am I missing?
Here is code (truncated):
import simplejson as json
import ordereddict
theJson = json.loads('{valid json}', object_pairs_hook=ordereddict.OrderedDict)
same error if I use import json
instead of simplejson