title: Create multidimensional json from HashMap<String, String>
body: <p>I need to create a multidimensional <code>json</code> from a <code>hashmap</code> which i have to generate from a .csv file.
  The <code>Hashmap</code> mapping from csv works fine.
  If i convert the created <code>Hashmap</code> with a simple <code>ObjectMapper</code> i just get an single dimension <code>json</code> with all attributes of the <code>HastMap</code>.</p>
  <p>Is it possible to check the <code>keys</code> of the <code>Hashmap</code> and if the key starts with &quot;baseData&quot; it gets in the subobject <code>baseData</code> like in the following <code>json</code>.</p>
  <pre><code>    {
      &quot;testCaseData&quot;: {
          &quot;baseData&quot;: {
              &quot;verkaufsproduktart&quot;: &quot;special&quot;,
              &quot;tarifgeneration&quot;: &quot;string&quot;,
              &quot;ursprungAngebotsnummer&quot;: &quot;string&quot;,
              &quot;mandant&quot;: &quot;string&quot;,
              &quot;sparte&quot;: &quot;string&quot;,
              &quot;beratungsprotokollId&quot;: &quot;string&quot;,
              &quot;bonitaet&quot;: &quot;string&quot;,
              &quot;verkaufsname&quot;: &quot;string&quot;,
              &quot;aktionsnummer&quot;: &quot;string&quot;,
              &quot;erstellernummer&quot;: &quot;string&quot;,
              &quot;verkaufsprozessart&quot;: &quot;string&quot;,
              &quot;kanalrichtung&quot;: &quot;string&quot;,
              &quot;versandweg&quot;: &quot;string&quot;,
              &quot;vertriebskanal&quot;: &quot;TELEFON&quot;,
              &quot;quellsystem&quot;: &quot;standard&quot;,
              &quot;kundenberater&quot;: &quot;String&quot;,
              &quot;vsnrErgoDirekt&quot;: &quot;string&quot;,
              &quot;vsnrRisikotraeger&quot;: &quot;string&quot;,
              &quot;versicherungen&quot;: [],
              &quot;leistungsvereinbarungen&quot;: [],
              &quot;beitraege&quot;: [],
              &quot;abbuchungstagImMonat&quot;: &quot;TAG_1&quot;,
              &quot;zahlweise&quot;: &quot;EINMALZAHLUNG&quot;,
              &quot;angebotsstatus&quot;: &quot;string&quot;,
              &quot;angebotsstatusaenderung&quot;: &quot;date&quot;,
              &quot;haustarif&quot;: true,
              &quot;versicherungsBeginn&quot;: &quot;2020-01-01&quot;,
              &quot;rabattWert&quot;: &quot;PROZENT_2&quot;
          },
          &quot;storeData&quot;: {
              &quot;personDataStore&quot;: [{
                  &quot;adresse&quot;: {
                      &quot;hausnummer&quot;: &quot;string&quot;,
                      &quot;land&quot;: &quot;Deutschland&quot;,
                      &quot;ort&quot;: &quot;string&quot;,
                      &quot;postleitzahl&quot;: &quot;string&quot;,
                      &quot;strasse&quot;: &quot;string&quot;
                  }]
           }
  }
  </code></pre>
  <p>The objectnames like <code>testCaseData</code> and <code>baseData</code> is fixed and known. the rest of the data inside <code>baseData</code> for example needs to be generic (thats why i use the <code>hashmap</code>).</p>
  <p>thanks for helping</p>
  <p>Edit:</p>
  <p>current Mapper</p>
  <pre><code>    public void getHashmapFromCsv(InputStream csvFile) throws IOException {
       HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
       BufferedReader br = new BufferedReader(new InputStreamReader(csvFile));
       List&lt;String&gt; completeInputList = 
   br.lines().collect(Collectors.toList());
       String[] baseLineArray = completeInputList.get(0).split(&quot;;&quot;);
       for (String singleCase : completeInputList.subList(1, 
   completeInputList.size())) {
           String[] singleCaseArray = singleCase.split(&quot;;&quot;);
           for (int i = 0; i &lt; baseLineArray.length; i++) {
               if (i &gt; singleCaseArray.length-1 || 
   singleCaseArray[i].equals(&quot;&quot;)) {
                   map.put(baseLineArray[i], null);
                   } else {
                       map.put(baseLineArray[i], singleCaseArray[i]);
                   }
               }
             
           }
           System.out.println(map);
           ObjectMapper Obj = new ObjectMapper().enable(SerializationFeature.WRAP_ROOT_VALUE);
           Obj.setSerializationInclusion(JsonInclude.Include.NON_NULL);
           String jsonStr = Obj.writeValueAsString(map); 
  
        } 
      }
  
  
  {baseData_kundenberaternummer=12346798, VP3 Kdnr=null, beratungsprotokollId=BERATUNGSVERZICHT, VP3 Nachname=null, VN Postleitzahl=90344, abbuchungstagImMonat=J, telemarketingnummer=123456789, VP4 Titel=null, baseData_aktionsnummer=1000, VP4 Hausnummer=null, mandant=1, VP3 Vorname=null, VP1 Vorname=null, VP4 baseData_Kdnr=null, VP3 Titel=null, VP1 Hausnummer=null, zahlweise=QUARTALSWEISE, VN Nachname=Mustermann, versandweg=EMAIL, VP3 Hausnummer=null, VP4 Ort=null, VP4 Anrede=null, VN Anrede=HERR, tuwid=null, VP2 Nachname=null, haustarif=N, VP2 Hausnummer=null, VP3 Strasse=null, VP2 Kdnr=null, iban=DE99999999, VP1 Nachname=null, VN Vorname=Max, VN baseData_Kdnr=null, VP2 Titel=null, vertriebskanal=TELEFON, VP2 Ort=null, VN Geburtsdatum=01.01.1980, VN Titel=null, VP1 Strasse=null, VP2 Strasse=null, VN Hausnummer=60, verkaufsproduktart=standart, quellsystem=system, VP3 Ort=null, rabattWert=0, VP4 Vorname=null, Testfallname=5, VP1 Anrede=null, VP2 Anrede=null, versicherungsBeginn=0, VN Strasse=street , VP2 Vorname=null, tarife=zzz, VP1 Kdnr=null, kundencm=J, verkaufsprozessart=DIREKTABSCHLUSS, VP1 Titel=null, gespraechspartner vorname=Hans, VP1 Postleitzahl=null, VP3 Anrede=null, kontoinhaber=Max Mustermann, userId=123456789, VN gleich VP=N, VN Ort=City, VP4 Strasse=null, gespraechspartner nachname=Meyer, versandmail=test@test.com, VP1 Ort=null, VP1 Geburtsdatum=null, VP2 Postleitzahl=null, VP4 Nachname=null, bankname=Bank, VP2 Geburtsdatum=null, VP3 Geburtsdatum=null, VP4 Postleitzahl=null, bic=NORSDE51XXX, VP3 Postleitzahl=null, VP4 Geburtsdatum=null}
  </code></pre>