I have a problem to search for objects inside objects

1

I download a JSON file, by example

asked by anonymous 14.07.2017 / 20:28

1 answer

0

There were two syntax errors in your script, a silly thing.

 for (i = 0; i = 

The equal sign there causes an infinite loop. Use .

for (i = 0; i < fileData.query.data.length; i++); {

And there's one; after the loop statement.

Your corrected code:

 var poeItem = new function() {
     this._getHTMLdata = function(fileData) {
         for (var i = 0; i < fileData.query.data.length; i++) {
             if (fileData.query.data[i] && fileData.query.data[i].property == 'Has_infobox_HTML') {
                 return fileData.query.data[i].dataitem[0].item
             }
         }
     }
 }
    
15.07.2017 / 03:34