0

I like to use the wikipedia entry API.

Ok, my JSON request looks like this:

var request = 'https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=berlin';

$.getJSON(request, function(data) {
   console.log(data)
})


What I get is something like this:

{"batchcomplete":"","query":{"pages":{"411322":{"pageid": 411322,"ns":0,"title":"Berlin","extract":"entry-text."}}}}

But how to extract the information with JSON extraction.

I tried to do:

var x=data.query.pages

But that didn't work for me, to extract Title and extract-text.

  • Use `var x = JSON.parse(data);` then you can do the extraction – David R Sep 16 '17 at 12:59
  • @DavidR Nope, when I parse the data I always get this error: `SyntaxError: JSON Parse error: Unexpected identifier "object".` –  Sep 16 '17 at 13:16

0 Answers0