Skip to content

Instantly share code, notes, and snippets.

@j2labs
Created September 3, 2012 15:10
Show Gist options
  • Save j2labs/3609974 to your computer and use it in GitHub Desktop.
Save j2labs/3609974 to your computer and use it in GitHub Desktop.
>>> import ujson as json
>>> jd = json.dumps
>>> json_is_ujson = True
>>>
>>>
>>> def dumps(data, sort_keys=False):
... if json_is_ujson:
... if sort_keys:
... raise Exception('ujson does not support sort_keys flag')
... return jd(data)
... else:
... return jd(data, sort_keys=sort_keys)
...
>>>
>>> json.dumps = dumps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment