title: How to get the value of a child node of a json array
body: <p>please i am having some issues parsing a list of data form the this link(<a href="https://gnews.io/api/v3/top-news?&amp;token=dd21eb88599ccb3411eaad9b314cde23" rel="nofollow noreferrer">https://gnews.io/api/v3/top-news?&amp;token=dd21eb88599ccb3411eaad9b314cde23</a>) i am able to get the data from the json array(articles) but how can i get the data from the josn array(sources) </p>
  
  <pre><code>    private void getWebApiData() {
          String WebDataUrl = "https://gnews.io/api/v3/top-news?&amp;token=dd21eb88599ccb3411eaad9b314cde23";
          new AsyncHttpTask.execute(WebDataUrl);
      }
  
      @SuppressLint("StaticFieldLeak")
      public class AsyncHttpTask extends AsyncTask&lt;String, Void, String&gt; {
  
          @Override
          protected String doInBackground(String... urls) {
              String result = "";
  
              URL url;
              HttpsURLConnection urlConnection = null;
              try {
                  url = new URL(urls[0]);
                  urlConnection = (HttpsURLConnection) url.openConnection();
                  if (result != null) {
                      String response = streamToString(urlConnection.getInputStream());
                      parseResult(response);
                      return result;
                  }
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(String result) {
              if (result != null) {
                  newsAdapter = new NewsAdapter(getActivity(), newsClassList);
                  listView.setAdapter(newsAdapter);
                  Toast.makeText(getContext(), "Data Loaded Successfully", Toast.LENGTH_SHORT).show();
  
              } else {
                  Toast.makeText(getContext(), "Failed to load data!", Toast.LENGTH_SHORT).show();
              }
              progressBar.setVisibility(View.GONE);
          }
      }
  
      private String streamToString(InputStream stream) throws IOException {
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream));
          String line;
          String result = "";
          while ((line = bufferedReader.readLine()) != null) {
              result += line;
          }
  
          // Close stream
          if (null != stream) {
              stream.close();
          }
          return result;
      }
  
  
      private void parseResult(String result) {
          try {
              JSONObject response = new JSONObject(result);
              JSONObject response2 = response.getJSONObject("articles");
              NewsClass newsClass;
              for (int i = 0; i &lt; newsClass.length(); i++) {
                  JSONObject post = newsClass.optJSONObject(i);
                  String name = post.optString("name");
                  newsClass = new newsClass();
                  newsClass.setNews_Name(name);
                  artistClassList.add(newsClass);
              }
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>This is code I am using the get the data of the articles.
  To get the sources I have tried</p>
  
  <pre><code>    private void parseResult(String result) {
          try {
              JSONObject response = new JSONObject(result);
              JSONObject response2 = response.getJSONArray("articles");
              JSONObject response3 = response2.getJSONObject("sources");
              NewsClass newsClass;
              for (int i = 0; i &lt; newsClass.length(); i++) {
                  JSONObject post = newsClass.optJSONObject(i);
                  String name = post.optString("name");
                  newsClass = new newsClass();
                  newsClass.setNews_Name(name);
                  artistClassList.add(newsClass);
              }
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>But I think I am not getting the code correctly</p>
  
  <p>Here is the second option I have tried</p>
  
  <pre><code>    private void parseResult(String result) {
          try {
              JSONObject response = new JSONObject(result);
  
              JSONObject response = response2.getJSONObject("sources");
              NewsClass newsClass;
              for (int i = 0; i &lt; newsClass.length(); i++) {
                  JSONObject post = newsClass.optJSONObject(i);
                  String name = post.optString("name");
                  newsClass = new newsClass();
                  newsClass.setNews_Name(name);
                  artistClassList.add(newsClass);
              }
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>But this only gives me empty text Fields the spaces for the data is populated but it is blank
  Please any help will be greatly appreciated</p>