Extracting User Data from JSON in Python

mail@pastecode.io avatar
unknown
python
a month ago
463 B
2
Indexable
Never
import json

with open('desafio.json', encoding='utf-8') as desafio_json:
    dados1 = json.load(desafio_json)
    print(dados1['user'][1]['email'])
    
with open('desafio.json', encoding='utf-8') as desafio_json:
    dados2 = json.load(desafio_json)
    print(dados2['user'][0]['address']['city'])

with open('desafio.json', encoding='utf-8') as desafio_json:
    dados3 = json.load(desafio_json)
    print(dados3['user'][1]['orders'][0]['total'])
Leave a Comment