public static String parseResponse(HttpResponse httpResponse,
			List bandListArray) throws ParseException, IOException {

		JSONArray response = new JSONArray();
		JSONParser jsonparser = new JSONParser();
		try {
			response = (JSONArray) jsonparser.parse(httpResponse
					.parseAsString());
			System.out.println(response.toString());
		} catch (ClassCastException ce) {
			System.err
					.println("Typecast failed. Response is probably broken. Can be caused by bad request");
		}
		String responseString = "";
		boolean candidateFound;
		for (int j = 0; j < response.size(); j++) {
			candidateFound = false;
			JSONObject responseEntry = (JSONObject) jsonparser.parse(response
					.get(j).toString());
			JSONObject responseEntryResult = (JSONObject) responseEntry
					.get("result");
			JSONArray responseEntryResultCandidates = (JSONArray) responseEntryResult
					.get("candidate");
			if (responseEntryResultCandidates == null) {
				responseString += bandListArray.get(j) + "\t" + "NO_MID_FOUND"
						+ "\t" + "0.0" + "\n";
				System.out.println("null result received -->"
						+ bandListArray.get(j));
			} else {

				/*
				 * a single entry can have multiple candidates It seems like the
				 * candidates are sorted by their confidence score TODO: look up
				 * whether this is reliable
				 */

				for (Object candidate : responseEntryResultCandidates) {
					responseString += (bandListArray.get(j)
							+ "\t"
							+ JsonPath.read(candidate, "$.mid").toString()
							+ "\t"
							+ JsonPath.read(candidate, "$.confidence")
									.toString() + "\n");
					// remove this break if you want to get more than one
					// result!
					break;
				}
			}
		}

		System.out.println(responseString);
		return (responseString);

	}