[英]Alexa with lambda function parsing json error
Developing Alexa with lambda function, json parsing error 使用Lambda函数开发Alexa,JSON解析错误
How to parse json response 如何解析JSON响应
{
"Status": true,
"Error": "",
"Data": [
{
"Traffic": 6231
}
],
"Message": null
}
My code 我的密码
result.Data[0].Traffic
error : 错误:
START RequestId: 4578b114-9bba-11e8-94a6-611a9b05be3f Version: $LATEST
2018-08-09T09:54:57.434Z 4578b114-9bba-11e8-94a6-611a9b05be3f Warning: Application ID is not set
2018-08-09T09:54:57.435Z 4578b114-9bba-11e8-94a6-611a9b05be3f traffic Plaza: sutpl1
2018-08-09T09:54:58.028Z 4578b114-9bba-11e8-94a6-611a9b05be3f TypeError: Cannot read property '0' of undefined
at IncomingMessage.res.on (/var/task/index.js:487:32)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
END RequestId: 4578b114-9bba-11e8-94a6-611a9b05be3f
REPORT RequestId: 4578b114-9bba-11e8-94a6-611a9b05be3f Duration: 654.57 ms Billed Duration: 700 ms Memory Size: 576 MB Max Memory Used: 34 MB
RequestId: 4578b114-9bba-11e8-94a6-611a9b05be3f Process exited before completing request
I found myself getting this error as well. 我发现自己也收到此错误。 Instead of appending with a period, try the following: result['Data']
to access the list and result['Data']['Traffic']
to get the value 6231. 代替附加句点,请尝试以下操作: result['Data']
访问列表,而result['Data']['Traffic']
获得值6231。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.