[Python] Processing Dictionary inside JSON [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have some code:

    import requests

    headers = {
    'authority': 'business.upland.me',
    'appversion': '0.13.24',
    'authorization': '(My auth code here)',
    'platform': 'web',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
    'content-type': 'application/json',
    'accept': '*/*',
    'sec-gpc': '1',
    'origin': 'https://play.upland.me',
    'sec-fetch-site': 'same-site',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    'referer': 'https://play.upland.me/',
    'accept-language': 'en-US,en;q=0.9',
    'if-none-match': 'W/^\\^10d-dcHHdBCD0xcI+3PFMmJm3d3EMaQ^\\^',
    }

    response = requests.get('https://business.upland.me/contributions/5804', headers=headers)
    stakersout = response.content
    stakersout = list(stakersout)
    print(stakersout)
    #get dictionaries here
    print(dictionary['username'])


    That returns some JSON:

    b'[{"id":"6078a1e0-9103-11eb-a53e-c9ee97fa6188","is_in_jail":false,"pending":false,"avatar_image":"https://upland-image.s3.amazonaws.com/avatars/exclusive/memo_day.svg","avatar_color":"#E900FD","price":0.46,"username":"cryptofan","created_at":"2021-06-25T02:10:35.825Z"}]'


    In this case, there is one dictionary inside but usually there will be more. How would I get each dictionary and process it in a for loop?

    Continue reading...

Compartilhe esta Página