json_demo.py 229 B

123456789101112
  1. ''' JavaScript Object Notation '''
  2. import json
  3. with open('states.json') as f:
  4. data = json.load(f)
  5. for state in data['states']:
  6. del state['area_codes']
  7. with open('new_states.json', 'w') as f:
  8. json.dump(data, f, indent=2)