我有一个触发 Lambda 的 AWS Stepfunction。不幸的是,我无法正确解码输入:
从 AWS Stepfunction 到 Lambda 的输入:
{
"MessageNumber": 0,
"message": {
"MessageId": "ae5b5d59-6829-4a19-b508-2ba35614e2de",
"ReceiptHandle": "AQEBJsP+Et+WcgstIR9kkA3sH4UDoxYYcoDT2YYa30K87Rx2wSEFaZNg3CNdsjE18LSDMNXWg7VoV/s/p0bSL0PaUxQ0FV34RAwavG0iGMi",
"MD5OfBody": "a726ec7fdda41e454850580e1a2cf4b4",
"Body": "{'stage': 'tst', 'directory': '\\\\\\\\mydomain\\\\data\\\\results', 'variableFilters': ['\\\\filters\\\\x1.txt', '\\\\filters\\\\a1.txt']}",
"Attributes": {
"SenderId": "xxx",
"ApproximateFirstReceiveTimestamp": "xxx",
"ApproximateReceiveCount": "2",
"SentTimestamp": "xxx",
"SequenceNumber": "xxx",
"MessageDeduplicationId": "xxx",
"MessageGroupId": "1"
}
}
}
Python代码如下:
def lambda_handler(event, context):
print(f'Received Event: {event}')
try:
body = json.loads(event.get('message').get('Body'))
stage = body["stage"]
directory= body["directory"]
except Exception as e:
return (e)
我收到错误:
{
"errorMessage": "Unable to marshal response: JSONDecodeError('Expecting property name enclosed in double quotes: line 1 column 2 (char 1)') is not JSON serializable",
"errorType": "Runtime.MarshalError"
}
有人知道如何解决这个问题吗?
素胚勾勒不出你
相关分类