Skip to content

Instantly share code, notes, and snippets.

@gbishop
Created September 3, 2010 18:51
Show Gist options
  • Save gbishop/564357 to your computer and use it in GitHub Desktop.
Save gbishop/564357 to your computer and use it in GitHub Desktop.
# monkey patch the python json module to handle undefined
import json
json.decoder._CONSTANTS['undefined'] = None
json.scanner.pattern('(-?Infinity|NaN|true|false|null|undefined)')(json.decoder.JSONConstant)
json.decoder.JSONScanner = json.decoder.Scanner(json.decoder.ANYTHING)
if __name__ == '__main__':
print json.loads('{ "foo": 1, "bar": undefined }')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment