From this query to the Wikipedia API:
http://en.wikipedia.org/w/api.php?action=query&prop=links&format=json&plnamespace=0& pllimit=10&titles=List%20of%20television%20programs%20by%20name
I get a JSON structure, e.g.:
var data = {
"query": {
"pages": {
"1536715": {
"pageid": 1536715,
"ns": 0,
"title": "List of television programs by name",
"links": [
{
"ns": 0,
"title": "$1.98 Beauty Show"
},
{
"ns": 0,
"title": "''Dance Academy''"
}
]
}
}
},
"query-continue": {
"links": {
"plcontinue": "1536715|0|15\/Love"
}
}
}
I want to work with the elements of the "links"
array. However, based on the existence of the element "pageid": 1536715
, I suspect the name of the nested object "1536715"
is a dynamic value that may change. I am reluctant to use this name to access the "links" array, e.g. query.pages.1536715.links
.
Is there any way to "step" past this object, i.e. with a wild card query.pages.*.links
? Failing that, can I iterate the children of pages
to get this object? I am using jQuery 1.7.2 for this project, in case you can suggest any helpful methods from there.