Is it possible to retrieve the name of the initial property within a JSON object?
I am interested in achieving something similar to this:
var firstProp = jsonObj[0];
edit: The JSON object I have contains categories with arrays of image URLs.
For example:
{
"category1":["image/url/1.jpg","image/url/2.jpg"],
"category2":["image/url/3.jpg","image/url/4.jpg"]
}
I am currently looping through the object to display the images, and I simply want to identify which category was displayed first. Initially, I used
for (var cat in images) {
if (i==0) firstCat = cat;
...
}
However, I found that approach to be somewhat unappealing... So my main focus is on finding a more elegant solution.