For jars, please read this post http://ampersandacademy.com/tutorials/java-json/

JSON Array class used to generate json array . Its like an arraylist.

You have to add JSON Object into JSON Array and print


import org.json.JSONArray;
import org.json.JSONObject;

public class GenArray {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		JSONArray json=new JSONArray();
		for(int i=0;i<5;i++)
		{
			Customer cust=new Customer();
			cust.setName("raja");
			cust.setAge(22);
			json.put(new JSONObject(cust));
		}
		System.out.println(json.toString());
	}

}


output:
[{"name":"raja","age":22},{"name":"raja","age":22},{"name":"raja","age":22},{"name":"raja","age":22},{"name":"raja","age":22}]

Here customer object added 5 times to JSON Array using for loop.