/** * @author lautturi.com * Java example:how to parse json string to JSONObject JSONArray in java */ import java.util.*; import org.json.JSONArray; import org.json.JSONObject; public class Lautturi { public static void main(String[] args) { String jsonString = "{\"employees\":[{\"id\":111,\"name\":\"Lautturi\"}, {\"id\":112,\"name\":\"James\"}]}"; JSONObject json = new JSONObject(jsonString); JSONArray arr = json.getJSONArray("employees"); System.out.println(arr); } }
output:
[{"name":"Lautturi","id":111},{"name":"James","id":112}]