AnsweredAssumed Answered

Accessing Non-Enumerable Nested Objects?

Question asked by cleotokos on Mar 18, 2016
Latest reply on Mar 21, 2016 by csgeosol1

I'm using YQL to get some html from a website so that I can scrape it for values. The site is 24 Hours Tidal Preliminary Observations - Tides, Currents, and Water Levels  (URL to be updated by javascript depending on the current day to get the last 24 hours of data) . The YQL REST query is https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.tides.gc.ca%2Fe… which returns JSON.

 

I'm trying to use Object.getOwnPropertyNames(obj) but it seems that I'm getting inconsistent results. Yesterday all property names within the object were being returned, today it seems only enumerable property names are being returned. I changed nothing from yesterday afternoon to this morning. If you visit this jsfiddle and open the console (in Google Chrome) you can see that the object contains a second nested object called "responseJSON", which is what I'm trying to access. In IE it's not showing the nested object I'm after, interestingly, when logging the main object - only showing enumerable property names.

 

Yesterday this returned ALL the property names to the Chrome console, as it should:

console.log(Object.getOwnPropertyNames(jqxhr));

 

Today it does not. I don't know how that's possible...yesterday I was able to access the portion of my desired data with:

 console.log(jqxhr["responseJSON"]["query"]["results"]["tr"]["100"]);

 

but no longer today. I get back that "responseJSON" is undefined.

 

Would appreciate hearing from anyone who has experience working with nested objects/arrays.

Outcomes