[英]running loop through json
This is my response and i want to run loop through the cards 这是我的回应,我想遍历卡片
{ success: true,
message: 'getcard success',
cards:
[ { cardid: '23',
cardtype: 'A',
status: 'A',
refername: 'rahulsgib',
refertype: 'G',
owner: 'rahul',
validate: true },
{ cardid: '25',
cardtype: 'A',
status: 'A',
refername: 'rahulsgib',
refertype: 'G',
owner: 'namita',
validate: true } ] }
what i tried is 我试过的是
for(var cards in response.cards) {
}
but it is not working and stops my node server , We have also used the hashish but i dont know that should i use hashish here and where should i use the hashish . 但是它不起作用并且停止了我的节点服务器,我们也使用了hashish,但是我不知道我应该在这里使用hashish还是在哪里使用hashish。
i tried this also 我也尝试过
var cards=response.cards;
self.log.debug('card '+cards.length);
for (var i=0; i<cards.length;i++) {
// self.log.debug('card '+sys.inspect(cards[i]));
}
but this also not working 但这也不起作用
Solved the problem , the problem was that self was not defined . 解决了问题,问题在于自己没有被定义。 and i was running through the upstart so error was not visible .when i runned by node server.js than error was visible.
而且我正在暴发户中运行,因此错误不可见。当我由节点server.js运行时,错误可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.