Using the json Library

The loads method in the json library returns a dictionary for anything in curly brackets and a list for anything in square brackets.

The following code shows interaction with dictionaries.

import json
data = '''{
"name": "John",
"phone": {
    "type": "intl",
    "number": "+1 111 222 3333"
},
"email": {
    "hide": "yes"
}
}'''

info = json.loads(data)
print('Name:', info['name'])
print('Hide:', info['email']['hide'])

The following code shows interaction with a list.

input = '''[
    {"id": "001",
        "x": "1",
        "name": "Jeff"
    },
    {"id": "002",
        "x": "2",
        "name": "John"
    }
]'''

info = json.loads(input)
for item in info:
    print('Name:', item['name'])
    print('ID:', item['id'])
    print('Attribute:', item['x'])