我有一个如下的 Json 数组:
[{"item":{"category Name":"T-e-PBS","SubCategory Name":"T-e-PBS"}},
{"item":{"category Name":"T-e-PBS","SubCategory Name":"Animals"}},
{"item":{"category Name":"T-e-PBS","SubCategory Name":"Birds"}},
{"item":{"category Name":"T-e-PBS","SubCategory Name":"Vegetables"}},
{"item":{"category Name":"T-e-PBS","SubCategory Name":"Colors"}},
{"item":{"category Name":"Rhymes","SubCategory Name":"Rhymes"}},
{"item":{"category Name":"Rhymes","SubCategory Name":"Animated Rhymes"}},
{"item":{"category Name":"Rhymes","SubCategory Name":"Cartoon Rhymes"}},
{"item":{"category Name":"Rhymes","SubCategory Name":"Prayers"}}]
我已经尝试但不知道如何获取类别明智的信息,因为我在类别下有很多子类别:
我想解析这个 JSON 字符串并根据类别填充数据。
如果我单击 Te-PBS 按钮,我应该能够在 gridview 中获取所有子类别,如 AnimalsImage、BirdsImages 等。
如果我单击押韵类别,我应该能够在网格视图中获得所有子类别。
有人可以帮忙吗?
我努力了:
JSONArray ja = new JSONArray(json);
int size = ja.length();
Log.d("tag","No of Elements " + ja.length());
for (int i = 0; i < size; i++) {
String str = ja.getString(i);
}