JSON Array Example in Java
This example will give JSON Array in java
import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class JSONArrayExample { /** * JSON Array Example in Java * This example helps how to use Array in JSON Object */ public static void main(String[] args) { JSONObject json=new JSONObject(); JSONArray jsonArr = new JSONArray(); jsonArr.add("json Array 1"); jsonArr.add("json Array 2"); jsonArr.add("json Array 3"); jsonArr.add("json Array 4"); System.out.println("json Array :"+jsonArr); json.put("key", jsonArr); System.out.println("json Object :"+json); } }
Output JSON Array
json Array :["json Array 1","json Array 2","json Array 3","json Array 4"]
json Object :{“key”:["json Array 1","json Array 2","json Array 3","json Array 4"]}
The post Java – JSON Array Example appeared first on Java Example.