[code.view]

[top] / python / PyMOTW / json / json_skipkeys.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2009 Doug Hellmann All rights reserved.
     #
     """
     """
     #end_pymotw_header
     
     import json
     
     data = [ { 'a':'A', 'b':(2, 4), 'c':3.0, ('d',):'D tuple' } ]
     
     print 'First attempt'
     try:
         print json.dumps(data)
     except ValueError, err:
         print 'ERROR:', err
     
     print
     print 'Second attempt'
     print json.dumps(data, skipkeys=True)
     

[top] / python / PyMOTW / json / json_skipkeys.py

contact | logmethods.com