I have a scenario where I am looping through a json response and trying to have a mapped key value pair.
objective : loop through the json file and search for values with name content1 inside the labels object if found then return the corresponding value of name(TEST API1) and id (33332) and store it in a variable or list to further store it in csv file with format name and id and content name and adding a sl num.
Here is what I have tried already:
get_metadata = requests.get('https://testurl.com')
metadata = get_metadata.json()
for key in metadata:
value = metadata[i]['labels']
print('The key and value are ({}) = ({})'.format(key, value))
Here error occurs:
Error: `TypeError: the JSON object must be str, bytes or bytearray,
not list`
How can I achieve the above objective what should be the approach any help would be great. If anybody can help here how to proceed further in this scenario.