title: Flatten json documents in Java
body: <p>I am a novice in Java and I am looking for a way to flatten json documents.</p>
  
  <p>I have tried Object mapper but without success. I found this link but the results is not what I need :<a href="https://github.com/wnameless/json-flattener" rel="nofollow noreferrer">https://github.com/wnameless/json-flattener</a></p>
  
  <p>I need to transform the documents  like in the example below :</p>
  
  <p>Here is an example of my documents</p>
  
  <p>Documents recieved:</p>
  
  <pre><code>{ 
                  "data1": "A", 
                  "data2": "B", 
                  "data3": "C", 
                  "data4": [{ 
                                 "subdata": [{ 
                                                 "subsubdata": "mam" 
                                 }, 
                                 { 
                                                 "subsubdata": "mom" 
                                 }, 
                                 { 
                                                 "subsubdata": "mim" 
                                 }] 
                  }] 
  } 
  </code></pre>
  
  <p>Documents Transformed :</p>
  
  <pre><code>{  
                  "data1": "A",  
                  "data2": "B",  
                  "data3": "C",  
                  "data4": [  
                                 {"subdata": {  
                                                 "subsubdata": "mam"  
                                              } 
                                 },  
                                 {"subdata" : {  
                                                 "subsubdata": "mom"  
                                              } 
                                 },  
                                 {"subdata" : {  
                                                 "subsubdata": "mim"  
                                              } 
                                 } 
                  ] 
  }  
  </code></pre>
  
  <p>Thanks</p>