showing results for - "parsing through json without using key value python"
Jannik
16 Mar 2016
1data = [
2  {
3    "id": 1,
4    "name": "Leanne Graham",
5    "username": "Bret",
6    "email": "Sincere@april.biz",
7    "address": {
8      "street": "Kulas Light",
9      "suite": "Apt. 556",
10      "city": "Gwenborough",
11      "zipcode": "92998-3874",
12      "geo": {
13        "lat": "-37.3159",
14        "lng": "81.1496"
15      }
16    },
17    "phone": "1-770-736-8031 x56442",
18    "website": "hildegard.org",
19    "company": {
20      "name": "Romaguera-Crona",
21      "catchPhrase": "Multi-layered client-server neural-net",
22      "bs": "harness real-time e-markets"
23    },
24    "other": ["This", "is", "a list"]
25  },
26  {
27    "id": 2,
28    "name": "Ervin Howell",
29    "username": "Antonette",
30    "email": "Shanna@melissa.tv",
31    "address": {
32      "street": "Victor Plains",
33      "suite": "Suite 879",
34      "city": "Wisokyburgh",
35      "zipcode": "90566-7771",
36      "geo": {
37        "lat": "-43.9509",
38        "lng": "-34.4618"
39      }
40    },
41    "phone": "010-692-6593 x09125",
42    "website": "anastasia.net",
43    "company": {
44      "name": "Deckow-Crist",
45      "catchPhrase": "Proactive didactic contingency",
46      "bs": "synergize scalable supply-chains"
47    },
48    "other": ["This", "is", "another list"]
49  },
50]    
51
52def show_indices(obj, indices):
53    for k, v in obj.items() if isinstance(obj, dict) else enumerate(obj):
54        if isinstance(v, (dict, list)):
55            yield from show_indices(v, indices + [k])
56        else:
57            yield indices + [k], v
58
59for keys, v in show_indices(data, []):
60    print(keys, v)