title: Convert csv directly to json with schema and json types
body: <p><strong>QUESTION:</strong> Can you use CsvMapper/CsvSchema to convert csv to a <code>map&lt;string, object&gt;</code> where the object is something other than string, like boolean or integer?  </p>
  
  <p><strong>Details:</strong> I have some csv files that I want to convert directly to json.  I don't have access to the POJO's.  But I do have an xml schema file that contains the type information for the columns in the csv data.</p>
  
  <p>After doing some searching I decided to use Jackson's CsvMapper/CsvSchema to convert the csv files to json.  I created a CsvSchema with column type information then converted the csv files to a Map&lt;> file then converted the map file to json.  It all worked fine except for one thing. All the json properties were Strings, even the properties that the CsvSchema had defined as Boolean and Numeric types.  Below is a small snippet that shows what I'm doing.</p>
  
  <pre><code>String csvEmployeeData="\"Bob\",25,true\n" +
                         "\"Joe\",35,false\n" +
                         "\"Tom\",45,false\n";
  
  CsvSchema schema = CsvSchema.builder().addColumn("name", ColumnType.String)
                                        .addColumn("age", ColumnType.NUMBER)
                                        .addColumn("isManager", ColumnType.BOOLEAN)
                                        .build();
  
  CsvMapper csvMapper = new CsvMapper();
  MappingIterator&lt;Map&lt;String, ? extends Object&gt;&gt; it = csvMapper.readerFor(Map.class)
                                                        .with(schema)                                                        
                                                        .readValues(csvEmployeeData);
  List&lt;Map&lt;String, ? extends Object&gt;&gt; objectList=it.readAll();
  Map&lt;String, ? extends Object&gt; employeeObj=objectList.get(0);
  
  assertEquals("java.lang.Integer", employeeObj.get("age").getClass().getTypeName());
  //        Integer age=(Integer)employeeObj.get("age");
  //        java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
  </code></pre>
  
  <p>I'm reading the csv data in to a Map where the string is the property name and the Object is value.  I thought the value type for Object would be based on the Schema ColumnType.  I.e. if it was a ColumnType.BOOLEAN then Object would be Boolean.  However all the Objects in the Map are String types.  </p>
  
  <p>I was assuming that the CsvSchema ColumnType's would be used in the conversion since in csv everything is a string so you don't need the schema for that.  I'm clearly missing something.  Surprisingly Google doesn't bring up a lot on using CsvMapper.</p>
  
  <p>Does anyone know if possible to go from CSV to json and use the json types (bool/integer) or does everything have to be a string?</p>