Search This Blog

Thursday, September 8, 2011

Easy way of making a JSON array of JSONarrays of JSONObjects ans so on ... in JAVA


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

No comments:

Post a Comment