【发布时间】:2021-09-28 03:06:55
【问题描述】:
以下是我想作为测试事件输入的内容,也是我的 lambda python 函数知道如何处理的内容。
{
"body": '{"email":"example@example.com","password":"Example1"}',
"path": "/SignIn"
}
但是,您不能将其配置为 aws lambda 中的测试事件,因为您会收到以下 - 有点合理 - 错误:
There is an error in your JSON event. Please correct it before saving.
这是有道理的,因为 JSON 中不应该有任何单引号。但是,如果我也使用所有双引号,它也不起作用。
有什么想法吗?漏洞?
【问题讨论】:
-
JSON 字符串必须使用双引号作为分隔符。与“body”关联的值应该是字符串还是嵌套对象?
-
如果必须是字符串,请尝试
"{\"email\":\"example@example.com\",\"password\":\"Example1\"}"。否则,只需去掉单引号。 -
太棒了!谢谢@PM2Ring,这正是我所需要的!
标签: python json amazon-web-services aws-lambda