JSON data consist of list and dictionary and can be persed using list index and dictionary keys as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from pprint import pprint data = { "company": "Cloudaffaire", "compcontacts": { "phone": "+91 97482 39853", "email": "contact@cloudaffaire.com" }, "employees": [ { "id": 101, "name": "Debjeet", "emails": ["debjeettoni@gmail.com","cloudaffaire@gmail.com"] }, { "id": 102, "name": "Chandrima", "Phone": ["+91 80177 02983"], "skills": [ { "cloud": "aws", "database": "mysql", "scripting": "python" } ] } ] } pprint(data) print(data["company"]) ## Returns Cloudaffaire print(data["compcontacts"]["email"]) ## Returns contact@cloudaffaire.com print(data["employees"][0]["name"]) ## Returns Debjeet print(data["employees"][0]["emails"][1]) ## Returns cloudaffaire@gmail.com print(data["employees"][1]["skills"][0]["cloud"]) ## Returne aws |