I have this line of code and I would like to drain numbers from the "list". Which is one good way to implement that? I am new to developing and this is a place I've been stuck for days.
protected Void doInBackground(Void... voids) {
try {
URL url = new URL("https://{myUrl}");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while (line != null){
line = bufferedReader.readLine();
data = data + line; }
JSONArray JA = new JSONArray(data);
for (int i = 0; i <JA.length(); i++ ){
JSONObject JO = (JSONObject) JA.get(i);
singleParsed = "list:" + JO.get("list");
dataParsed = dataParsed + singleParsed;
} } catch (MalformedURLException e) {
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace(); } catch (JSONException e) {
e.printStackTrace(); }
return null; }
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
MainActivity.data.setText(this.dataParsed);
} ```
JSON file
{
"common":{
"mixed":"yes",
"nums":{
"list":[
1,
2,
3,
4
],
"other":[
5
]
}}
}