I'm trying to get usernames from logs. The server outputs them as json. In the example below, I need all usernames. Nothing I've tried so far worked. Any help is appreciated.
logs = [
"nt5510-clark\\clark63",
{
"guid": "A07BB2CD",
"name": "srvfs01",
"ips": [
"10.10.1.210"
]
},
{
"guid": "DB2A9C9E",
"name": "nt5510-clark",
"ips": [
"10.6.100.40"
]
},
{
"guid": "97F7AEEC",
"name": "lapinf-msa",
"ips": [
"192.168.0.32"
]
},
"stephen.robertson",
"christian",
{
"guid": "C888A5B2",
"name": "nb-mcsorley",
"ips": [
""
]
}
]
username_list = [value for (key,value) in logs.items() if key in logs]
Output:
username_list = [value for (key,value) in logs.items() if key in logs]
AttributeError: 'list' object has no attribute 'items'
Expected Output:
["nt5510-clark\\clark63","srvfs01","nt5510-clark","lapinf-msa","stephen.robertson","christian","nb-mcsorley"]