取json中的键值(json中键值不固定的时候)

//json数据中所有的键值
Iterator<String> keys = jsonObject.keys();
ArrayList<String> list0 = new ArrayList<String>();
while(keys.hasNext()){
String key = keys.next();
list0.add(key);
}
for (char i = 'A';  i <= 'Z';  i++) {
List<BrandListInfo> list_brand_list = new ArrayList<BrandListInfo>();
if(list0.contains(i+"")){
JSONArray brand0 = jsonObject.optJSONArray(i+"");
for(int j = 0;j<brand0.length();j++){
JSONObject j1 = brand0.optJSONObject(j );
String id = j1.optString("id");
String brand_name = j1.optString("brand_name");
String brand_letter = j1.optString("brand_letter");
String brand_logo = j1.optString("brand_logo");
BrandListInfo info = new BrandListInfo(id, brand_name, brand_letter, brand_logo);
list_brand_list.add(info);
}
list_all.add(list_brand_list);
list_brand_list.clear();
}
}

你可能感兴趣的:(取json中的键值(json中键值不固定的时候))