title: Convert CSV to JSON array in Java Springboot
body: <p>Hi I am trying to convert a CSV file into a JSON array using A dependency called csvReader, but when I run the code it prints out the JSON response incorrectly and I ament sure why would anyone be able to point me in the right direction.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    @GetMapping("/convert")
      public List&lt;List&lt;String&gt;&gt; convertCSV() throws FileNotFoundException {
          List&lt;List&lt;String&gt;&gt; records = new ArrayList&lt;List&lt;String&gt;&gt;();
      try (CSVReader csvReader = new CSVReader(new FileReader("C:/Download/cities.csv"));) {
          String[] values = null;
  
      while ((values = csvReader.readNext()) != null) {
          records.add(Arrays.asList(values));
      }
  
  } catch (IOException e) {
              e.printStackTrace();
          }
          return values;
      }</code></pre>
  </div>
  </div>
  
  <a href="https://i.stack.imgur.com/zgD9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zgD9L.png" alt="enter image description here"></a></p>