I am trying to get the output of a JSON response into a easier to read table with column headers. I am running into the problem of trying to access the specific JSON information. Here is what I have so far
import json
import requests
import pandas as pd
url = requests.get('https://apitest.com/api/scanners',auth=('', ''))
r = json.loads(url.content)
a = r['items']
My response is in this format here
I want to be able to append this information with the information of scanner name, antenna number and the last scan date, so I can eventually create a dataframe with the column headers
d = []
for h in a:
d.append(
{ 'ScannerName': h['name'],
'AntennaNumber':h['antennae']['antenna'],
'LastScanDate': h['antennae']['lastScanDate']
}
)
I receive a "TypeError: list indices must be integers or slices, not str" at this point. I wanted to know if anybody has any suggestions on a possible solution or if I need to approach this in a different way. Thank you.