Quantcast
Channel: Active questions tagged nessus - Stack Overflow
Viewing all articles
Browse latest Browse all 232

How to read JSON (in mentioned format)?

$
0
0

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.


Viewing all articles
Browse latest Browse all 232

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>