Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> d = {'age': 27,
- ... 'name': 'Joe',
- ... 'numbers': [1,
- ... 2,
- ... 3,
- ... 4,
- ... 5],
- ... 'subdict': {
- ... 'first': 1,
- ... 'second': 2,
- ... 'third': 3
- ... }
- ... }
- >>>
- >>> from pprint import pprint
- >>> pprint(d)
- {'age': 27,
- 'name': 'Joe',
- 'numbers': [1, 2, 3, 4, 5],
- 'subdict': {'first': 1, 'second': 2, 'third': 3}}
- >>>
- In [109]: simplejson.loads(simplejson.dumps({'d':(12,3,4,4,5)}))
- Out[109]: {u'd': [12, 3, 4, 4, 5]}
- import simplejson
- my_structure = {"name":"Joe", "age":27, "numbers":[1,2,3,4,5], "subdict":{"first":1, "second":2, "third": 3}}
- json = simplejson.dumps(my_structure)
- {"age": 27, "subdict": {"second": 2, "third": 3, "first": 1}, "name": "Joe", "numbers": [1, 2, 3, 4, 5]}
- import pprint
- pprint.pprint(my_structure)
- {'age': 27,
- 'name': 'Joe',
- 'numbers': [1, 2, 3, 4, 5],
- 'subdict': {'first': 1, 'second': 2, 'third': 3}}
- {'age': 27,
- 'name': 'Joe',
- 'numbers': [1,
- 2,
- 3,
- 4,
- 5],
- 'subdict': {
- 'first': 1,
- 'second': 2,
- 'third': 3
- }
- }
Add Comment
Please, Sign In to add comment