package massiveattendancescannerapplication.Services; import massiveattendancescannerapplication.Data.Course; import massiveattendancescannerapplication.Data.Section; import java.io.IOException; import java.util.*; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /**
* This class parses a JSON Object which is received from the Main Activity. * The methods in this class are private except for GetQuestionary(),which is the main call for * this class to parse,fill the questions objects and return an ArrayList consisting of several * question objects that later are used to construct the survey. *
* @author Reynaldo */ public class JSONParser { public static ArrayList* This function receives a JSON object and parses trough all the elements until a Course * tag is reached. The JSON object contains various nested JSON Arrays that represent * different levels of the survey info, such as Courses, Sections, and Students, * these arrays must be parsed in order to reach the courses that are needed to construct * the list. Once the Course tag is reached, the function calls * readCourses(JSON Object). *
* * @param json a JsonObject containing Courses info. * @return an ArrayList containing various course objects. * @throws JSONException if JSON object is empty or null. */ private static ArrayList