I have to parse and get the 'id'
field value alone (i.e 13
in this case) from the below JSON response. My JSON response will be in the below format. This is get policies nessus call
{'policies': [{'creation_date': 1546583582,
'description': 'New Scan',
'has_credentials': 0,
'id': 13}]}
My code:
import requests
from first import *
url = 'https://localhost:8834/policies'
headers = {'X-Cookie':mys()}
response = requests.get(url, headers=headers, verify=False)
resp = response.json()
for k,v in resp.items():
print (v)
Code response:
[{'creation_date': 1546583582,'description': 'New Scan','has_credentials': 0,'id': 13}]
I'm unsure how to write a code to get the result as expected response - 'id' : 13
or just 13
.