XMen
XMen

Reputation: 30238

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 .

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

Upvotes: 0

Views: 629

Answers (1)

XMen
XMen

Reputation: 30238

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.

Upvotes: 1

Related Questions