Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

python json nested dictionaries

mydict = {   
   'items': [
       {
           'id': '12345',
           'links': {'self': 'https://www.google.com'},
           'name': 'beast',
           'type': 'Device'
       }
    ],
    'links': {'self': 'https://www.google.com'},
    'paging': {
        'count': 1,
        'limit': 1,
        'offset': 0,
        'pages': 1
    }
}

If I want to get "id", "self", "name",

print(mydict['items'][0]['id'])
print(mydict['items'][0]['links']['self'])
print(mydict['links']['self'])
print(mydict['items'][0]['name'])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #json #nested #dictionaries
ADD COMMENT
Topic
Name
7+9 =