我如何在android中访问此结构的JSONArray

时间:2015-01-12 08:27:03

标签: android json

大家好,我仍然在android和json中找到自己的脚,并且发现访问此表单的json结构时遇到了困难。

下面是我想在json数组文件中使用

访问的json数组的一部分
"Topics": [
"ABIRABƆ",
"PƐYƐ",
"KASAKOA",
"DODOƆ KABEA",
"EDIN",
"EDIN NKYERƐKYERƐMU",
"EDINNSIANANMU",
"ADEYƐ",
"ƆKYERƐFOƆ",
"NKABOMDEƐ",
"NTAMGYINAFOƆ"
 ],

我希望在"主题"

下获取所有值的值

非常感谢帮助谢谢

1 个答案:

答案 0 :(得分:4)

怎么样

{"Topics": [
    "ABIRABƆ",
    "PƐYƐ",
    "KASAKOA",
    "DODOƆ KABEA",
    "EDIN",
    "EDIN NKYERƐKYERƐMU",
    "EDINNSIANANMU",
    "ADEYƐ",
    "ƆKYERƐFOƆ",
    "NKABOMDEƐ",
    "NTAMGYINAFOƆ"
]}

JSONObject jso = getCodeAboveAsJSONObject(); //however you wish to do that.
JSONArray topics = jso.getJSONArray("Topics");

for (int i = 0; i < topics.length(); i++) {
    String s = topics.getString(i);
    // do something with String s
}