如何在邮递员测试脚本中的JSON响应领域中逃脱结肠
我正在使用请求的JSON响应编写邮递员测试脚本,并且其中一个字段名称为aaa:bbb
。如何在测试脚本中使用此字段?当我尝试按原样使用它时,我会收到语法错误。
我的脚本只是试图打印字段值:
let res = pm.response.json();
res.results.forEach((e) => {
console.log(e.aaa:bbb);
})
我尝试了以下所有内容,但它们不起作用:
e.'aaa:bbb'
e。“ aaa:bbb”
e.aaa \:bbb
e.jsonvalue ['aaa:bbb']
什么是正确的逃生字符或正确的方法?
I'm writing a postman test script using the JSON response for a request, and one of the field name is named like aaa:bbb
. How do I use this field in the test script? When I try using it as it is, I get a Syntax error.
My script is just trying to print the field value:
let res = pm.response.json();
res.results.forEach((e) => {
console.log(e.aaa:bbb);
})
I tried all of the following but they do not work:
e.'aaa:bbb'
e."aaa:bbb"
e.aaa\:bbb
e.jsonValue['aaa:bbb']
What is the correct escape character or the right way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与Postman没有太多经验,但是您是否尝试过
e ['AAA:BBB']
。Don't have too much experience with postman but have you tried
e['aaa:bbb']
.