I'm working on retrieving information from HPQC which I've successfully converted into a json object and then in turn into a Python object (i.e. a dictionary), but I'm running into trouble getting values out of the resulting dict.
I've done a fair amount of research on it already, and I'm starting to get the information I need...but not all of it.
The general structure of the json/dict I'm working with is as follows:
*'v' indicates contents of the {} above it
Entities:{@Total:81
Entity:[{},{},{},...,{}]
v
{@Type:<type>
Fields:{}
} v
{Field:[{},{},{},...,{}]
} v
{@Name:<name>
Value:<value
}
}
As stated, I'm able to print out the names and values with the following code:
with requests.Session() as req:
req.post(authenticate_url, verify=False, auth=(usnm, pswd))
request = req.get(url, verify=False)
# responseToJSON just converts the response object to a JSON and then to a python object
request = responseToJSON(request)
for entry in js_dict[u'Entities'][u'Entity']:
for nest_entry in entry[u'Fields'][u'Field']:
print nest_entry[u'@Name']
# Not all Names have a Value
if u'Value' in nest_entry:
print " " * 4, nest_entry[u'Value']
else:
print " " * 4, "No Value!"
Based on the @Total value, there should be 81 "Entity" dictionaries, each with Fields-Field-Name/Value. The for loop I was using before the one here only printed out the the name and value for each Field dict, giving me a total of 15 results. With the current version, I managed to increase this to 23.
I exported the json object to a file in the same request process I used immediately before the for loop, and all 81 "Entity" objects are definitely there, so it shouldn't be a matter of an incomplete data retrieval.
Is there some sort of check or something I'm missing? Or would the large amount of objects be causing it to stop early for some reason? Or something else entirely?