/**
   * Converts a map of results to a String JSON representation for it
   *
   * @param map a map that matches properties with an ArrayList of values
   * @return the JSON representation for the map, as a String
   */
  private String mapToString(Map<String, ArrayList<String>> map) {
    StringBuilder result = new StringBuilder("{");
    for (Map.Entry<String, ArrayList<String>> entry : map.entrySet()) {
      ArrayList<String> value = entry.getValue();
      if (value.size() == 1)
        result.append(String.format("\"%s\" : %s,\n", entry.getKey(), value.get(0)));
      else result.append(String.format("\"%s\" : %s,\n", entry.getKey(), value.toString()));
    }

    result.setCharAt(result.length() - 2, '}');
    return result.toString();
  }