Android-从json获取数据

Android-从json获取数据,android,json,Android,Json,我有一个返回此json对象的api调用: { "elenco": [ "folder 1", "folder 2", "folder 3" ], "codice": "123456789" } 这是我得到结果的一段代码: protected void onPostExecute(JSONObject result) { // Close progress dialog Dialog.dis

我有一个返回此json对象的api调用:

{
    "elenco": [
        "folder 1",
        "folder 2",
        "folder 3"
    ],
    "codice": "123456789"
}
这是我得到结果的一段代码:

protected void onPostExecute(JSONObject result) {

        // Close progress dialog
        Dialog.dismiss();

        JSONObject jobj = null;
        String codice_utente = null;
        JSONArray elenco_cartelle = null;

        try {

            jobj = new JSONObject(String.valueOf(result));

        } catch (JSONException e) {
            e.printStackTrace();
        }

        //Provo a recuperare i campi json
        try {

            codice_utente = jobj.getString("codice");
            elenco_cartelle = jobj.getJSONArray("elenco");

        } catch (JSONException e) {
            e.printStackTrace();
        }

        //This should fetch the elenco array
        for (int i = 0; i < elenco_cartelle.length(); i++) {  

            JSONObject childJSONObject = null;

            try {

                childJSONObject = elenco_cartelle.getJSONObject(i);

            } catch (JSONException e) {
                e.printStackTrace();
            }

           //Can't use getString here...

        }



    }
我怎样才能拿到elenco的部分?我没有要使用的键,因此如何添加ArrayList中的每一行? 我尝试使用for,但不知道如何使用JSONArray.getString获取行


您现在可以在内容中找到您的内容了

谢谢Pedro,解决方案比我想象的要简单得多!我将尽快接受//此处无法使用getString。。。为什么要这样评论?因为我认为我应该像对待codice那样使用这个方法
for (int i = 0; i < elenco_cartelle.length(); i++) {  

            String content = null;

            try {

                content = elenco_cartelle.getString(i);

        } catch (JSONException e) {
            e.printStackTrace();
        }

       //Can't use getString here...

    }