[I have some code to create a JSON array. In this code I am passing some values to x
, y
, z
in a loop which looks like this.
JSONArray list = new JSONArray();
String jsonText = null;
for (int j = 0; j < 4; j++) {
list.add(new Integer(x));
list.add(new Integer(y));
list.add(new Integer(z));
jsonText = list.toString();
}
System.out.print(jsonText);
This gives output as
[1234,245,10,312,234,122,1234,67788,345,235,001,332]
How can I get these values in a single array like this?
[[1234,245,10],[312,234,122],[1234,67788,345],[235,001,332]]] I got the answer for this question needs answer for the below question.
I used one of the below solutions. Thanks for the response from you guys.
Now i got JSON formate nested Arrays which looks like this
[
[[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]]]
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
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.
Thanks friends for helping me till now.