title: How to get json object as per spinner selection
body: <p>I am getting name and date in my spinner from this response,now what i am trying is if user select lily from spinner then i want to get occ value in string,but i am not getting it,following is my response and code,can any one tell me that what is the issue</p>
  
  <pre><code>[
      {
          "friend_id": "1",
          "user_spoc_dob": "1993-11-11",
          "status": "true",
          "spouse_name": "lily",
          "occ": "spoc"
      },
      {
          "friend_id": "1",
          "user_mother_dob": "1974-12-12",
          "status": "true",
          "mother_name": "sita",
          "message": "Address details Not available",
          "occ": "mom"
      },
      {
          "friend_id": "1",
          "user_father_dob": "1972-11-19",
          "status": "true",
          "father_name": "ram",
          "message": "Address details Not available",
          "occ": "dad"
      },
      {
          "friend_id": "1",
          "user_dob": "1994-02-20",
          "status": "true",
          "user_fname": "Su",
          "occ": "spl"
      }
  ]
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code> protected ArrayList&lt;String&gt; doInBackground(
                  String... args) {
              ServiceHandler sh = new ServiceHandler();
  
              statedata = new ArrayList&lt;String&gt;();
              String jsonStr = sh.makeServiceCall(STATE_URL, ServiceHandler.GET);
              Log.d("Response: ", "&gt; " + jsonStr);
              if (jsonStr != null) {
                  try {
                      jsonObj = new JSONArray(jsonStr);
                      for (int i = 0; i &lt; jsonObj.length(); i++) {
  
  
                          JSONObject c = jsonObj.getJSONObject(i);
                          String wifebday= (c.has("user_spoc_dob")) ? c.getString("user_spoc_dob") : null;
                          String wifename= (c.has("spouse_name")) ? c.getString("spouse_name") : null;
                          String mothersbday= (c.has("user_mother_dob")) ? c.getString("user_mother_dob") : null;
                          String mothersname= (c.has("mother_name")) ? c.getString("mother_name") : null;
                          String fatherbday= (c.has("user_father_dob")) ? c.getString("user_father_dob") : null;
                          String fathername= (c.has("father_name")) ? c.getString("father_name") : null;
                          String ownbbday= (c.has("user_dob")) ? c.getString("user_dob") : null;
                          String ownname= (c.has("user_fname")) ? c.getString("user_fname") : null;
                          occs= (c.has("occ")) ? c.getString("occ") : null;
                          System.out.println("Bday" + wifebday + mothersbday + fatherbday + ownbbday);
                          // if test, to avoid adding null values
                          if(wifebday!=null) statedata.add(wifename+"  :  "+wifebday);
                          if(mothersbday!=null) statedata.add(mothersname+"  :  "+mothersbday);
                          if(fatherbday!=null) statedata.add(fathername+"  :  "+fatherbday);
                          if(ownbbday!=null) statedata.add(ownname+"  :  "+ownbbday);
  
  
                          testlist=new ArrayList&lt;String&gt;();
                          if(occs!=null) testlist.add(occs);
  
                      }
  
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              } else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
              return statedata;
          }
  
          protected void onPostExecute(ArrayList&lt;String&gt; result) {
              super.onPostExecute(result);
              pDialog.dismiss();
              arrallstates = new String[statedata.size()]; // you can also use "result" array instead
              for (int index = 0; index &lt; statedata.size(); index++) {
                  arrallstates[index] = statedata.get(index);// or result.get(index);
                  //arrallstates[index] =testlist.get(index);
              }
              // pass arrConuntry array to ArrayAdapter&lt;String&gt; constroctor :
              adapterallstates = new ArrayAdapter&lt;String&gt;(
                      WishFriendsFamily.this.getActivity(),
                      android.R.layout.simple_spinner_dropdown_item, arrallstates);
              System.out.println("adpttest" + adapterallstates);
              staticSpinner.setAdapter(adapterallstates);
  
              staticSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                  @Override
                  public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
  
                          String oocs=testlist.get(i).toString();
                      System.out.println("slected ocs" + oocs);
                  }
                  @Override
                  public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  
                  }
              });
          }
      }
  </code></pre>