In my code, I had to make a JSONArray of JSONArrays which have JSONObjects which in turn can be JSONArrays.
When we try to do it in pure JSON way, it gets complicated, we have to create a lot of different variables and then add it to the main array.
There is a very simple way to do it. Just keep on creating a HashMap which can be a HashMap of HashMaps and so on.
Then when you create a JSONArray pass the HashMap to it as a variable to its constructor. It creates an entire JSONArray from it.
Thanks,
Shoeb