CSV to JSON conversion in Java Since I've looked far and wide for a good example of this to no avail, I have created my own using the JSONArray and JSONObject classes. It took me a while to realize that the push method for JSONObject overwrites everything previously pushed.

public static JSONArray getJSON(String url) throws IOException, JSONException, URISyntaxException, TransformerException{
        HttpClient httpClient = new DefaultHttpClient();
        JSONArray jArray = new JSONArray();
        Object[] q = null;
        Deque&lt;String&gt; queue = new ArrayDeque&lt;String&gt;();

        try{  
            HttpGet httpGet = new HttpGet(url);
            HttpResponse response = httpClient.execute(httpGet);
            int responseCode = response.getStatusLine().getStatusCode();
            logger.info("Response Code : " + responseCode);
            if (responseCode != 404){
                logger.info("Response" + response.getEntity().getContent());
                try(BufferedReader reader = new BufferedReader(
                       new InputStreamReader(
                               response.getEntity().getContent()))) {

                 if(reader != null){
                     String aux = "";
                     while ((aux = reader.readLine()) != null) {
                         queue.add(aux);
                     }
                     q = queue.toArray();

                     for(int i = 0; i &lt; q.length; i++){

                         String[] row = q[i].toString().split(",");

                            JSONObject json = new JSONObject();
                            json.put("col0", row[0]);
                            json.put("col1", row[1]);
                            json.put("col2", row[2]);
                            json.put("col3", row[3]);
                            json.put("col4", row[4]);
                            json.put("col5", row[5]);

                            jArray.put(json);


                     }
                 }
                }

             }
                }
                return null;

             }
             return jArray;
        }finally{
            httpClient.getConnectionManager().shutdown();
        }
    }
It would be nice if you provide some information about the libraries used in your code. For example, if I want to read about JSONArray and JSONObject, which json library do I need to search for?

The same observation goes for the java classes HttpGet, HttpResponse, HttpClient and DefaultHttpClient. Showing the imports of those classes would also be helpful.

Having said that I only have one suggestion to your code. It seems like you don't need to create the array of Objects from the queue of strings (Object[] q = queue.toArray();), you could just iterate over the elements in the queue and then process each element. 

Instead of adding elements to the jArray object this way

        while ((aux = reader.readLine()) != null) {
            queue.add(aux);
        }
        q = queue.toArray();

        for (int i = 0; i &lt; q.length; i++) {
            String[] row = q[i].toString().split(",");
            JSONObject json = new JSONObject();
            json.put("col0", row[0]);
            json.put("col1", row[1]);
            json.put("col2", row[2]);
            json.put("col3", row[3]);
            json.put("col4", row[4]);
            json.put("col5", row[5]);
            jArray.put(json);
        }


I would add the elements in this other way 

        while ((aux = reader.readLine()) != null) {
            queue.add(aux);
        }

        for (String row : queue){
            String[] csvValues = row.toString().split(",");
            JSONObject json = new JSONObject();
            json.put("col0", csvValues[0]);
            json.put("col1", csvValues[1]);
            json.put("col2", csvValues[2]);
            json.put("col3", csvValues[3]);
            json.put("col4", csvValues[4]);
            json.put("col5", csvValues[5]);
            jArray.put(json);
        }