title: How to get particular value from JSON response in Android?
body: <p>I want to get the value of <code>"result"</code> from the below JSON response and store it locally.Here's the code:</p>
  
  <pre><code>private class GetContacts extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected Void doInBackground(Void... arg0) {
              // Creating service handler class instance
              ServiceHandler sh = new ServiceHandler();
  
              // Making a request to url and getting response
              String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
              if (jsonStr != null) {
                      try {
                          JSONObject jsonObj = new JSONObject(jsonStr);
  
                          //JSONArray contacts;
                          contacts = jsonObj.getJSONArray("response");
                          Log.d("Response: ", "&gt; " + contacts);
  
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  } else {
                      Log.e("ServiceHandler", "Couldn't get any data from the url");
                  }
                  return null;
          }
      }
  </code></pre>
  
  <p>My Response :</p>
  
  <pre><code>{"response":
  
          [{
              "name":"ajay",
              "class":"7",
          },
  
          {
              "rank":1
          }],
  
  
          "date":
  
          {
              "startdate":2/12/2012,
          },
              "result":"pass"
          }
  </code></pre>