我有一个看起来像这样的JSON对象
{"layout":[["12","21","31"],["empty","22","32"],["13","23","33"]]}
我正在尝试使用以下内容获取数组数据:
JSONObject layoutJson;
JSONArray layoutData = layoutJson.getJSONArray();
但是我最终在
数组中输入了一个条目[["12","21","31"],["empty","22","32"],["13","23","33"]]
如何以3个数组的形式从JSON对象中获取它?
答案 0 :(得分:0)
JSONObject layoutJson;
JSONArray layoutData = layoutJson.getJSONArray();
for (int i = 0; i < layoutData.length(); i++) {
JSONObject firstArray = (JSONObject)layoutData.getJSONObject(i);
// Do whatever you want with first array
// you can loop through the first array again
}