Code example for JSONArray

Methods: getJSONObjectlength

0
	} 
	 
	public List<ModerationComplaint> parse(String json) throws ParsingException {
		final List<ModerationComplaint> complaints = Lists.newArrayList();
		try { 
			JSONArray complaintsJSON = new JSONArray(json);
			for (int i = 0; i < complaintsJSON.length(); i++) {
				JSONObject complaintJSON = complaintsJSON.getJSONObject(i);
				int id = complaintJSON.getInt(ID);
				String status = complaintJSON.getString("status");
				complaints.add(new ModerationComplaint(userParser.jsonToUser(complaintJSON.getJSONObject("user")), parseDate(complaintJSON.getString("date")).toDate(),
						complaintJSON.getString("type"), complaintJSON.has("notes") ? complaintJSON.getString("notes") : null, id, status));
			}			 
			 
		} catch (JSONException e) {
			e.printStackTrace();
			throw new ParsingException(); 
		} 
		return complaints;
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE