如何解决转义Json属性名称
NodeJs Lambda应该返回有效载荷
{ “状态代码”:200, “身体”: { “ Customer_Code”:“ CCode”, “ c_type _ / _ customer_type”:“客户类型” } }
请注意缩写名称中的“ /”
我无法在Lambda中转义此属性名称
这有效
exports.handler = async (event) => {
// TODO implement
event.ctype__customer_type = "Customer Type";
const response = {
statusCode: 200,body: event,};
return response;
};
但不是这个
exports.handler = async (event) => {
// TODO implement
event.ctype__customer_type = "Customer Type";
const response = {
statusCode: 200,};
return response;
};
任何线索。干杯
解决方法
为什么不使用bracket notation:
event [“ c_type _ / _ customer_type”]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。