title: Convert nested arbitrary JSON to CSV in Java
body: <p>This question has been asked many times but I couldn't find the answer that fixes my issue.</p>
  
  <p>I'm trying to convert nested JSON format to CSV format like this  :</p>
  
  <p>The <strong>JSON structure is arbitrary</strong> and <strong>could be anything</strong>, nested or not.</p>
  
  <p>I'm not suppose to know it, it's a database answer and I need to export this JSON answer into CSV file.</p>
  
  <p>Here is an <strong>example</strong> </p>
  
  <p>Input : </p>
  
  <pre><code>   {
      "_id": 1,
      "name": "Aurelia Menendez",
      "scores": [
                {
                   "type": "exam",
                   "score": 60.06045071030959
                 },
                 {
                   "type": "quiz",
                   "score": 52.79790691903873
                 },
                 {
                  "type": "homework",
                  "score": 71.76133439165544
                 }
               ]
            }
  </code></pre>
  
  <p>The output I'm looking for :</p>
  
  <pre><code>_id,name,scores.type,scores.score,scores.type,scores.score,scores.type,scores.score  
   1,Aurelia Menendez,exam,60.06...,quiz,52.79...,homework,71.76..
  </code></pre>
  
  <p>This is an example, it could be any other JSON document. </p>
  
  <p>The idea here is to use dot notation in the CSV column name. </p>
  
  <p>I've already used CDL but the output is not what I want :</p>
  
  <pre><code>_id scores  name
   1  "[{score:60.06045071030959,type:exam},{score:52.79790691903873,type:quiz},{score:71.76133439165544,type:homework}]" Aurelia Menendez
  </code></pre>
  
  <p>So how can I convert nested JSON to CSV with dot notation and in a generic way ?</p>
  
  <p><strong>Edits</strong></p>
  
  <p>Deserialisation of the JSON with <strong>Jackson</strong> :</p>
  
  <pre><code>   ObjectMapper mapper=new ObjectMapper();
  
      JsonNode jsonNode=mapper.readValue(new File("C:\\...\\...\...\\test.json"), JsonNode.class);
  </code></pre>
  
  <p>Ismail</p>