Wikipedia project help

Wikipedia project help
0

#1

How to get the data title, extract and url from following json file . Is it data.query.pages[0].title is correct for title

{
    "batchcomplete": "",
    "continue": {
        "gsroffset": 10,
        "continue": "gsroffset||"
    },
    "query": {
        "pages": {
            "43059671": {
                "pageid": 43059671,
                "ns": 0,
                "title": "Foreign policy of the Narendra Modi government",
                "index": 8,
                "extract": "<p>The <b>foreign policy of Narendra Modi</b> (also referred to as the <b>Modi Doctrine</b>) concerns the policy initiatives made towards other states by the current Modi government after he assumed office as Prime Minister of India on 26 May 2014.</p>\n<p>The Ministry of External Affairs, headed by External Affairs Minister Sushma Swaraj (the first woman to hold the office since Indira Gandhi), is responsible for carrying out the foreign policy of India. Modi's foreign policy is currently focused on improving relations with neighbouring countries in South Asia, engaging the extended neighbourhood in Southeast Asia and the major global powers. In pursuit of this, he has made official visits to Bhutan, Nepal and Japan within the first 100 days of his government, followed by the United States, Myanmar, Australia, and Fiji.</p>\n<p>Swaraj has also made official visits to Bangladesh, Bhutan, Nepal, Myanmar, Singapore, Vietnam, Manama, Bahrain, Afghanistan, Tajikistan, United States, United Kingdom, Mauritias, Maldives, United Arab Emirates, South Korea, China, Oman and Sri Lanka.</p>\n<p></p>",
                "contentmodel": "wikitext",`indent preformatted text by 4 spaces`
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr",
                "touched": "2016-11-01T00:50:28Z",
                "lastrevid": 747187021,
                "length": 122799,
                "fullurl": "https://en.wikipedia.org/wiki/Foreign_policy_of_the_Narendra_Modi_government",
                "editurl": "https://en.wikipedia.org/w/index.php?title=Foreign_policy_of_the_Narendra_Modi_government&action=edit",
                "canonicalurl": "https://en.wikipedia.org/wiki/Foreign_policy_of_the_Narendra_Modi_government"
            },
}
}
}

#2

It should be data.query.pages["43059671"].title. You can loop through all these with:

for(var page in data.query.pages){ 
  console.log(data.query.pages[page].title); 
}

Or you can use Object.keys()


#3

Thank you very much @BenGitter. It working like a charm.