title: Java , Csv to json , jackson-dataformat-csv
body: <p>I am novice in java and  I want to convert csv file into json </p>
  
  <p>I'am using the following code example to convert csv file into json file,
  the things is, I have got an error on the" withSchema(bootstrap) "  it says : "The method with(CsvSchema) is undefined for the type ObjectReader" 
   and I do not know how to fix it, I have change maven dependencies to the version 2.9.0, try withtype(bootstrap) withCsvSchema(bootstap) but still not working .</p>
  
  <p>Thanks</p>
  
  <p>Here is the code :</p>
  
  <pre><code>package CsvData;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.List;
  import java.util.Map;
  
  import com.fasterxml.jackson.databind.MappingIterator;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.fasterxml.jackson.dataformat.csv.CsvMapper;
  import com.fasterxml.jackson.dataformat.csv.CsvSchema;
  
  public class csvjson {
  
      public static void main(String[] args) throws Exception {
          File input = new File("/x/data.csv");
          File output = new File("/x/data.json");
  
          List&lt;Map&lt;?, ?&gt;&gt; data = readObjectsFromCsv(input);
          writeAsJson(data, output);
      }
  
      public static List&lt;Map&lt;?, ?&gt;&gt; readObjectsFromCsv(File file) throws IOException {
          CsvSchema bootstrap = CsvSchema.emptySchema().withHeader();
          CsvMapper csvMapper = new CsvMapper();
          MappingIterator&lt;Map&lt;?, ?&gt;&gt; mappingIterator = csvMapper.reader(Map.class).with(bootstrap).readValues(file);
  
          return mappingIterator.readAll();
      }
  
      public static void writeAsJson(List&lt;Map&lt;?, ?&gt;&gt; data, File file) throws IOException {
          ObjectMapper mapper = new ObjectMapper();
          mapper.writeValue(file, data);
      }
  }
  </code></pre>