title: Add list of objects in JsonObject in java
body: <p>I have the list of objects as below</p>
  
  <pre><code>List&lt;sampleClass&gt; data = .....;
  </code></pre>
  
  <p>How do I add this list as value to "sample" in the below code?</p>
  
  <pre><code>JsonObject a = Json.createObjectBuilder()
                         .add("abz", "xyz")
                         .add("sample", data)
                         .build();
  </code></pre>
  
  <p>If data has </p>
  
  <pre><code>        { 
            "a" : 2,
            "b" : 3
          }
  </code></pre>
  
  <p>I want the output to be </p>
  
  <pre><code>{
      "abz": "xyz",
      "sample": [{
          "a": 2,
          "b": 3
      }]
  }
  </code></pre>