「Java開発」Json配列からArrayListに変換するサンプル

Javaコード
public static List<Map<String, Object>> getList(String jsonString)
{
List<Map<String, Object>> list = null;
try
{
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject jsonObject;
list = new ArrayList<Map<String, Object>>();
for (int i = 0; i < jsonArray.length(); i++)
{
jsonObject = jsonArray.getJSONObject(i);
list.add(getMap(jsonObject.toString()));
}
}
catch (Exception e)
{
e.printStackTrace();
}
return list;
}

Comments are closed.