'access JSON sub-object without knowing key value

For example, assuming I can generate this page but won't be able to hard-code the article number, how can I access the thumbnail link in this entry?

https://en.wikipedia.org/w/api.php?action=query&titles=Arcadius&prop=pageimages&format=json&origin=*&pithumbsize=100



Solution 1:[1]

assuming that json is a name of your json object, you can try this

var thumbnail = json["query"]["pages"]["2180"]["thumbnail"];

// or thumbnail source

var source = json["query"]["pages"]["2180"]["thumbnail"]["source"];

if you have a json string , not an object you will have to parse it at first

var json=JSON.Parse(jsonString);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serge