I am trying to get text from a Wikipedia article using their API (the API is a generous term for what they offer, but we will use it, I think), and I am having problems parsing the subsequent JSON object I return. Namely, the object contains the text that I am looking for under the key, whose label is "*", so after executing the command:
$.getJSON("http://en.wikipedia.org/w/api.php?action=parse&format=json&callback=?", {page:"Red Sea clownfish", prop:"text"}, function(data) {
Then I try to parse this information in a line using the command:
var dat = data.parse.text.*;
Then I output to the console using:
console.log(dat);
Unfortunately, neither Google Chrome nor Firefox seems to be able to parse the '*' key. When I delete the complete "data" object in the console, I see that the (nested) keys for the data structure are "parse", "text" and '*' . I can even reset the text that I need to the key "*". I.e.
var dat = data.parse.text;
works. Itβs just that this β*β symbol does not want to be recognized.
Any ideas on how to fix this? Ideally, I would like to access a value that refers to the "*" key. I just don't know how to program it in javascript.
source share