'Trying to Parse a JSON using Python but having issues

I usually use Powershell and have parsed JSONs from HTTP requests, successfully, before. I am now using Python and using the 'Requests' library. I have successfully got the JSON from the API. Here is the format it came through in (I removed some information and other fields).:

{'content': [
    {
    'ContactCompany': Star,
    'ContactEmail': [email protected],
    'ContactPhoneNumber': 123-456-7894, 
     'assignedGroup': 'TR_Hospital', 
     'assignedGroupId': 'SGP000000132297',  
     'serviceClass': None, 'serviceReconId': None
     }
            ]
}

I'm having trouble getting the values inside of the 'content.' With my Powershell experience in the past, I've tried:

tickets_json = requests.get(request_url, headers=api_header).json()

Tickets_Info = tickets_json.content

for tickets in tickets_info: tickets.assignedGroup

How do I parse the JSON to get the information inside of 'Content' in Python?



Solution 1:[1]

tickets_json = requests.get(request_url, headers=api_header).json()

tickets_info = tickets_json['content']

for tickets in tickets_info: 
    print(tickets['assignedGroup'])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexandru Placinta