I have an AWS Lambda function that returns this:
{'Records': [{'EventSource': 'aws:sns', 'EventVersion': '1.0', 'EventSubscriptionArn': 'deleted', 'Sns': {'Type': 'Notification', 'MessageId': 'ID', 'TopicArn': 'deleted', 'Subject': None, 'Message': '{"addressLength": {"NULL":true},"lName":{"NULL":true},"zipCode":{"NULL":true},"loanType": {"S":"Car"},"city":{"NULL":true},"birthDate":{"NULL":true},"loanAmount": {"N":"100000"},"ssn":{"NULL":true},"emailAddress": {"S":"[email protected]"},"fName":{"S":"Testy"},"phoneNumber": {"S":"2220009999"},"streetAddress":{"NULL":true},"LoanBotTableId": {"S":"85863390"},"state":{"NULL":true}}', 'Timestamp': '2019-09- 24T06:09:37.025Z', 'SignatureVersion': '1', 'Signature': 'deleted', 'SigningCertUrl': 'URL', 'UnsubscribeUrl': 'URL', 'MessageAttributes': {}}}]} I am trying to get the Message information. When I use Message = event['Records'][0]['Sns']['Message']
I get:
{ "addressLength": { "NULL": true }, "lName": { "NULL": true }, "zipCode": { "NULL": true }, "loanType": { "S": "Car" }, "city": { "NULL": true }, "birthDate": { "NULL": true }, "loanAmount": { "N": "9000" }, "ssn": { "NULL": true }, "emailAddress": { "S": "[email protected]" }, "fName": { "S": "haad" }, "phoneNumber": { "S": "9099999999" }, "streetAddress": { "NULL": true }, "LoanBotTableId": { "S": "39765985" }, "state": { "NULL": true } } When I use
Message = event['Records'][0]['Sns']['Message']['phoneNumber']['S'] I get an
[ERROR] TypeError: string indices must be integers
Can someone help me get the information?