title: How to get values in variable from jsonObject?
body: <p>I have response like this from my Soap Web Service as follows:</p>
  
  <pre><code>    [{"msg":"1,UDDAIPUR","Value1":null,"Value2":null,"Value3":null,"Value4":null,"Value5":null,"Value6":null,"Value7":null,"Value8":null,"Value9":null,"Value10":null}]
  </code></pre>
  
  <p>Below is my AsyncTask -</p>
  
  <pre><code>//String TAG_IDS And TAG_NAMES
  private static final String TAG_ID_fillstateid = "nSerialNo";
  
  //TO call web service for City
  class async_fillCity extends AsyncTask&lt;String, Void, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
  
          SoapObject request = new SoapObject(namespace, method_name__fillcity);
          request.addProperty(parameter_fillcity, "1");//add the parameters
  
          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);//set soap version
          envelope.setOutputSoapObject(request);
          envelope.dotNet = true;
          try {
              HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
              androidHttpTransport.call(soap_action_fillcity, envelope);  // this is the actual part that will call the webservice
              //SoapPrimitive prim = (SoapPrimitive) envelope.getResponse();  // Get the SoapResult from the envelope body.
              SoapObject response = (SoapObject) envelope.bodyIn;
              //resultstate = prim.toString();
              resultcity = response.getPropertyAsString(0).toString();
  
              if (resultcity != null) {
                  try {
  
                      JSONArray resultarray = new JSONArray(resultcity);
                      for (int i = 0; i &lt; resultarray.length(); i++) {
                          JSONObject c = resultarray.getJSONObject(i);
                          String idCity = c.getString(TAG_ID_fillstateid);
                          String nameCity = (c.getString(TAG_Name_fillstatename));
                          HashMap&lt;String, String&gt; hashstate = new HashMap&lt;String, String&gt;();
                          hashstate.put(TAG_ID_fillstateid, idCity);
                          hashstate.put(TAG_Name_fillstatename, nameCity);
                          resultListstate.add(hashstate);
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              } else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }
          return resultcity;
  
      }
  
      @Override
      protected void onPostExecute(String result1) {
          // TODO Auto-generated method stub
          final SpinnerAdapter adapter = new SimpleAdapter(MainActivity.this, resultListstate, R.layout.activity_showspinner_state, new String[]{TAG_ID_fillstateid, TAG_Name_fillstatename}, new int[]{R.id.textidstate, R.id.textnamestate});
  
          city.setAdapter(adapter);
  
          city.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) {
                  // TODO Auto-generated method stub
  
                  TextView txtid = (TextView) findViewById(R.id.textidstate);
                  City = txtid.getText().toString();
                  // Call web service for district
                  //calldistt();
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
                  // TODO Auto-generated method stub
              }
          });
          super.onPostExecute(result1);
  
      }
  }
  </code></pre>
  
  <p>I am getting error:</p>
  
  <blockquote>
    <p>"org.json.JSONException: No value for nSerialNo"</p>
  </blockquote>