Oct-28-2019, 04:51 PM
Thanks Craig. That worked fine. Following the same logic I then added
computer_dictionary['service_health'] = {'services': computer_dictionary['health']['services']['status']}I thought this would add new key to the dictionary with the service health.
computer_keys = ('id', 'hostname', 'lastSeenAt', 'threats', 'service_health', 'tamperProtectionEnabled', 'ipv4Addresses', 'associatedPerson', 'health') #Add the computers to the computers list for all_computers in computers_json["items"]: # Make a temporary Dictionary to be added to the sub estate list computer_dictionary = {key:value for key, value in all_computers.items() if key in computer_keys} if 'health' in computer_dictionary.keys(): #computer_dictionary['health'] = {'threats': computer_dictionary['health']['threats']['status']} computer_dictionary['health'] = {'overall': computer_dictionary['health']['overall']} computer_dictionary['service_health'] = {'services': computer_dictionary['health']['services']['status']} #computer_dictionary['health'] = {'threats': computer_dictionary['health']['threats']['status']} # seems to work computer_list.append(computer_dictionary)If I comment out this line it works fine
computer_dictionary['health'] = {'overall': computer_dictionary['health']['overall']}I was thinking I would get the result of each sub key and then make a new key for the result. This will make it easier when I export it to CSV at the end.