package javaapplication7; import java.io.IOException; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class JavaApplication7 { public static void main(String[] args) throws IOException { int[] ids = {10, 20, 30, 40, 50}; String[] names = {"Zied", "Jean", "Rose", "Dupon", "Max"}; boolean[] status = {true, false, true, false, false}; JSONArray mainArray = new JSONArray(); JSONObject mainObject = new JSONObject(); for (int i = 0; i < ids.length; i++) { mainObject.accumulate("id", ids[i]); mainObject.accumulate("name", names[i]); mainObject.accumulate("status", status[i]); mainArray.add(mainObject); mainObject.clear(); } System.out.println(mainArray); FileWriter.saveStringIntoFile("json/studentList.json", mainArray.toString()); } }