sir mordred sir mordred - 11 months ago 45
JSON Question

Json parsing in Java, returning main elements

İm working on java project (originally android project) that does json parsing

Originally im trying to find page id from title

İ have the following json string that have information about page id but i cant return the page id 3434750

How can i acces array that contains "pageid" "ns" and "title" without knowing key(3434750) ?

How can i do it?

Thanx in advance

json string

Answer

Get json object "pages" and Loop throw it by using iterator

Iterator<String> iterator = json.keys();
while (iterator .hasNext()) {
    String key = iterator .next();
    try {
        Object value = json.get(key);
    } catch (JSONException e) {

    }
}