I have a nested dictionary that I am trying to parse and do not seem to know how to access the third level items. Help is appreciated Here is my dictionary
{
"FunctionName": "RDSInstanctStart",
"LastModified": "2018-03-24T07:19:56.792+0000",
"MemorySize": 128,
"Environment": {
"Variables": {
"DBInstanceName": "test1234"
}
},
"Version": "$LATEST",
"Role": "arn:aws:iam::xxxxxxx:role/lambda-start-RDS",
"Timeout": 3,
"Runtime": "python2.7",
"TracingConfig": {
"Mode": "PassThrough"
},
"CodeSha256": "tBdB+UDA9qlONGb8dgruKc6Gc82gvYLQwdq432Z0118=",
"Description": "",
"VpcConfig": {
"SubnetIds": [],
"SecurityGroupIds": []
},
"CodeSize": 417,
"FunctionArn": "arn:aws:lambda:us-east-1:xxxxxxxx:function:RDSInstanctStart",
"Handler": "lambda_function.lambda_handler"
}
I am trying to access the value for the key "Variables" Here is my code so far:
try:
for evnt in funcResponse['Environment']['Variables']['DBInstanceName']:
print (evnt[0])
except ClientError as e:
print(e)
The result I get is
t
e
s
t
1
2
3
4
If I do not give the Index of the envt variable, I get a type error.
dpathor one of its competitors to treat the nested collection as a flat collection with complex paths like'Environment/Variables/DBInstanceName'for keys.