title: How to get correct format json in spring
body: <p>I'm using RestTemplate and JSONObject to get data from db and send post to server
  My service:</p>
  <pre><code>List&lt;MyMap&gt; customerList = customerService.getAllCustomerViewBasicInfo(params);
  </code></pre>
  <p>customerList will get all data from database</p>
  <p>My Controller:</p>
  <pre><code>    JSONArray ja = new JSONArray();
      ja.put(customerList);
  
      JSONObject obmain1 = new JSONObject();
      obmain1.put(&quot;actionType&quot;, &quot;update-contact&quot;);
      obmain1.accumulate(&quot;data&quot;, ja);
  
      JSONArray jomain1 = new JSONArray();
      jomain1.put(obmain1);
  
      JSONObject jomain = new JSONObject();
      jomain.put(&quot;userSender&quot;, &quot;myemail@gmail.com&quot;);
      jomain.put(&quot;data&quot;, jomain1);
  
      System.out.println(jomain);
  </code></pre>
  <p>When I get data it have result following as: (wrong format)</p>
  <pre><code>{
    &quot;userSender&quot;: &quot;myemail.com&quot;,
    &quot;data&quot;: [
    {
      &quot;actionType&quot;: &quot;update-contact&quot;,
      &quot;data&quot;: [
        [
          [
          {
            &quot;name&quot;: &quot;TEST&quot;,
            &quot;lastname&quot;: &quot;TESTER&quot;,
            &quot;phones&quot;: &quot;0165458852&quot;,
            &quot;addresses&quot;: &quot;TEST&quot;,
            &quot;passport&quot;: &quot;870402152364&quot;,
            &quot;customerType&quot;: &quot;company&quot;
          },
          {
            &quot;name&quot;: &quot;TEST&quot;,
            &quot;lastname&quot;: &quot;TESTER1&quot;,
            &quot;phones&quot;: &quot;0165458852&quot;,
            &quot;passport&quot;: &quot;870402152364&quot;,
            &quot;customerType&quot;: &quot;company&quot;
          }
          ]
         ]
       ]
       }
      ]
     }
  </code></pre>
  <p>but it is wrong format...</p>
  <p>and I want to get correct format and expect following as: (correct format)</p>
  <pre><code>{
  &quot;senderUser&quot;: &quot;myemail.com&quot;,
  &quot;data&quot;: [
      {
          &quot;actionType&quot;: &quot;update-contact&quot;,
          &quot;data&quot;: {
              &quot;name&quot;: &quot;LƯƠNG BẢO  &quot;,
              &quot;lastname&quot;: &quot;LONG&quot;,
              &quot;type&quot;: 0,
              &quot;title&quot;: &quot;ms&quot;,
              &quot;passport&quot;: &quot;123123&quot;,
              &quot;gender&quot;: 1,
              &quot;dateOfBirth&quot;: &quot;03-01-2021&quot;,
              &quot;emails&quot;: [
                  {
                      &quot;value&quot;: &quot;myemail.com&quot;
                  }
              ],
              &quot;phones&quot;: [
                  {
                      &quot;value&quot;: &quot;0902032618&quot;
                  }
              ],
              &quot;addresses&quot;: [
                  {
                      &quot;addressDetail&quot;: &quot;osaka&quot;,
                      &quot;street&quot;: &quot;36 osaka&quot;,
                      &quot;city&quot;: &quot;Tokio&quot;,
                      &quot;state&quot;: &quot;Tokio&quot;,
                      &quot;country&quot;: {
                          &quot;code&quot;: &quot;JP&quot;,
                          &quot;name&quot;: &quot;japan&quot;
                      }
                  }
              ],
              &quot;cusFields&quot;: [
                  {
                      &quot;600f9cb0f02f084bd8a3dcdb&quot;: &quot;TEST&quot;
                  },
                  {
                      &quot;600fbc6ef02f084bd8a3f7bd&quot;: &quot;TEST2&quot;
                  },
                  {
                      &quot;600fbc6ef02f084bd8a3f7be&quot;: &quot;TEST3&quot;
                  }
              ],
              &quot;customerType&quot;: &quot;company&quot;,
              &quot;600f9cb0f02f084bd8a3dcdb&quot;: &quot;SME&quot;
          }
      }
  ]
  }
  </code></pre>
  <p>How can I get correct data as expect? many thank</p>