Get Value from Random Key in JSON


I’m making a simple application with http requests. I managed to get back the result from first API(Google Translate). But I can’t get any results from second one.

The API I’m trying to get result:

The output is:

    "batchcomplete": "",
    "query": {
        "normalized": [
                "from": "masa",
                "to": "Masa"
        "pages": {
            "219000": {
                "pageid": 219000,
                "ns": 0,
                "title": "Masa",
                "description": "\u00fcst\u00fc d\u00fcz mobilya",
                "descriptionsource": "central"

As you can see every time when I request something ‘pageid’ is changing and I can’t declare any keys for this JSON.

My Flutter Code:

var transurl = Uri.parse(
    var response = await,
        body: {'q': sonuc, 'source': 'en', 'target': 'tr', 'format': 'text'});
    if (response.statusCode == 200) {
      var harita = jsonDecode(utf8.decode(response.bodyBytes)) as Map;
      var ceviri = harita['data']['translations'].last['translatedText'];
      var wikiurl = Uri.parse(
      var wikii = await, body: {});
      var wikibilgi = jsonDecode(utf8.decode(wikii.bodyBytes)) as Map;
      var wikiii = (wikibilgi['query']['pages']); //Don't know what to write here.
//Don't know what to write here.
              builder: (context) =>
                  BilgiEkrani(sonuc: sonuc, oran: oran, wikibilgi: wikiii)));
    } else {
          content: Text("GOOGLE TRANSLATE API HATASI"),
          duration: const Duration(seconds: 2)));


You can get the first key of the map (your pageid) with:

var wikipageId = wikibilgi['query']['pages'].keys.toList()[0]; 

To get the content, you can then just use that key.

var wikiii = wikibilgi['query']['pages'][wikipageId];

Answered By – joscha

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published