vijay
1/10/2015 - 7:09 AM

Fetching Data From JSONObject

Fetching Data From JSONObject

    try {

				JSONArray arr = new JSONArray(response);

				if (arr.length() != 0) {
					Log.d("javavk", arr + "");
    //when i don't have object name;
					for (int i = 0; i < arr.length(); i++) {

						JSONObject jObj = arr.getJSONObject(i);

						email = jObj.getString("email");
						registration = jObj.getString("registration");
						active = jObj.getString("active");
						referred = jObj.getString("referred");
						send_count = jObj.getString("send_count");
						send_dates = jObj.getString("send_dates");

						arrayList.add(new Shop_referal_Model(email,
								registration, active, referred, send_count,
								send_dates));

					}

					Log.d("checkjson9", email + "");

				}

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Log.d("checkjosn9", e.toString() + " I catched");
			}
JSONObject jsonObject;
try {
   Log.d("sfp", "before if");
   // arr = new JSONArray(response);
   JSONObject reader = new JSONObject(response);

   String name;
   String email;

   
   jsonObject = reader.getJSONObject("userdata");

   name = jsonObject.getString("name");
   email = jsonObject.getString("email");

   Log.d("5jan", "" + name);
   Log.d("5jan", "" + email);

  } catch (JSONException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Log.d("5jan", e.toString() + " I catched");
  }