title: How to get a specific json key value from post request response in Android?
body: <p>I have following response from post request using <code>HttpURLConnection</code>:</p>
  
  <p>Post Request Response:</p>
  
  <pre><code>{
      "LatestData": [{
          "ExtraData": null,
          "ID": 0,
          "season": false,
          "latest": 0,
          "url": "http://www.awebsite.com/images/12.jpg"
      }]
  }
  </code></pre>
  
  <p>How to get value of URL? I tried following but Android Studio keeps giving me error:</p>
  
  <pre><code>String newURL = sb.getJSONObject("LatestData").getString("url");
  String newURL = sb.getJSONArray("LatestData").getJSONObject(0).getString("url");
  </code></pre>
  
  <p>Android Studio Error:</p>
  
  <pre><code>error: cannot find symbol method getJSONObject(String)
  error: cannot find symbol method getJSONArray(String)
  </code></pre>
  
  <p>could you guys help me obtain the value of url and let me know what libraries i need to import to android studio so getsonObject works ?Thanks</p>
  
  <p>android code:</p>
  
  <pre><code> if (myURLConnection.getResponseCode() == 200) {
                  br = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream(), "utf-8"));
                  while (true) {
                      line = br.readLine();
                      if (line != null) {
                          sb.append(line + "\n");
  
  
                          //String newURL = sb.getJSONObject("LatestData").getString("url");
                          String newURL =sb.getJSONArray("LatestData").getJSONObject(0).getString("url");
                          mWebView.loadUrl("javascript:MyFunction('" +newURL + "');");
                      } else {
                          br.close();
                          return sb.toString();
                      }
                  }
              }
  </code></pre>