so you need to call the server to get the jsonString you can make service call like this by passing url and getting the json str
public String makeServiceCall(String reqUrl) {
String response = null;
try {
URL url = new URL(reqUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
InputStream in = new BufferedInputStream(conn.getInputStream());
response = convertStreamToString(in);
} catch (MalformedURLException e) {
Log.e(TAG, "MalformedURLException: " + e.getMessage());
} catch (ProtocolException e) {
Log.e(TAG, "ProtocolException: " + e.getMessage());
} catch (IOException e) {
Log.e(TAG, "IOException: " + e.getMessage());
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
return response;
}
then you use the jsonStr you get from the call like this.
String jsonStr = makeServiceCall(String reqUrl);
JSONArray jsonArr= new JSONArray(jsonStr);
JSONObject jsonObjectOne = jsonArr.getJSONObject(0);
String param1 = jsonObjectOne.getString("param1");
JSONObject jsonObjectTwo = jsonArr.getJSONObject(1);
String param2 = jsonObjectTwo.getString("param2");