title: JSON for Java, Encode a JSON array - Streaming
body: <p>[I have some code to create a JSON array. In this code I am passing some values to <code>x</code>, <code>y</code>, <code>z</code> in a loop which looks like this.</p>
  
  <pre><code>   JSONArray list = new JSONArray();
     String jsonText = null;
     for (int j = 0; j &lt; 4; j++) {
         list.add(new Integer(x));
         list.add(new Integer(y));
         list.add(new Integer(z));
         jsonText = list.toString();
    }
    System.out.print(jsonText);
  </code></pre>
  
  <p>This gives output as</p>
  
  <pre>[1234,245,10,312,234,122,1234,67788,345,235,001,332]</pre>
  
  <p>How can I get these values in a single array like this?</p>
  
  <p><pre>[[1234,245,10],[312,234,122],[1234,67788,345],[235,001,332]]</pre> ] I got the answer for this question needs answer for the below question.</p>
  
  <p>I used one of the below solutions.
  Thanks for the response from you guys. </p>
  
  <p>Now i got JSON formate nested Arrays which looks like this </p>
  
  <pre><code>[
  [[1234,245,10],[312,234,122],[1234,67788,345],[235,001,332]],
  [[1234,245,10],[312,234,122],[1234,67788,345],[235,001,332],[1234,67788,3450]],
  [[1234,245,10],[312,234,122],[1234,67788,345],[235,001,332],[1234,67788,34534]]]
  </code></pre>
  
  <p>SO i have One big Array which contains three arrays(this can be 2 or more than three arrays sometimes) and each of these three array contains some arrays, in this above example   </p>
  
  <p>what is the reverse procedure ? i mean what if i want those values from these arrays. In the same way how i have did. using JSON
  JSONArray list = new JSONArray();
  list.get()  this get method will give me what i requies ?
  I used the org.json Java API. </p>
  
  <p>Thanks friends for helping me till now.</p>