Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. [
  2. {
  3. "firstname": abc,
  4. "lastname": xyp,
  5. "designation" : executive,
  6. "user": {
  7. "username": "xypabc",
  8. "userid": 4003,
  9. },
  10. },
  11.  
  12. {
  13. "firstname": pqr,
  14. "lastname": vbn,
  15. "designation" : security,
  16. "user": {
  17. "username": "vbnpqr",
  18. "userid": 11231,
  19. },
  20. },
  21.  
  22.  
  23. {
  24. "firstname": ghk,
  25. "lastname": lkj,
  26. "designation" : manager,
  27. "user": {
  28. "username": "lkjghk",
  29. "userid": 774,
  30. },
  31. }
  32. ]
  33.  
  34. try {
  35. JSONArray jsonObj = new JSONArray(response);
  36. for(int i=0 ; i<jsonObj.length(); i++)
  37. {
  38. JSONObject json_Data = jsonObj.getJSONObject(i);
  39. String userName = json_Data.getString("username");
  40. String userId = json_Data.getString("userid");
  41. Log.d("Factors","UserName :- "+userName+" ID :- "+userId);
  42. }
  43. }catch (JSONException e) {
  44. Log.d("Failure","Dude I have failed");
  45. }.
  46.  
  47. for(int i=0 ; i<jsonObj.length(); i++)
  48. {
  49. JSONObject json_Data = jsonObj.getJSONObject(i);
  50. String userName = json_Data.getJSONObject("user").getString("username");
  51. String userId = json_Data.getJSONObject("user").getString("userid");
  52. Log.d("Factors","UserName :- "+userName+" ID :- "+userId);
  53. }
  54.  
  55. try {
  56. JSONArray jsonObj = new JSONArray(response);
  57. for(int i=0 ; i<jsonObj.length(); i++)
  58. {
  59. JSONObject json_Data = jsonObj.getJSONObject(i);
  60. JSONObject user = json_Data.getJSONObject("user");
  61. String userName = user.getString("username");
  62. String userId = user.getString("userid");
  63. Log.d("Factors","UserName :- "+userName+" ID :- "+userId);
  64. }
  65. }catch (JSONException e) {
  66. Log.d("Failure","Dude I have failed");
  67. }
  68.  
  69. JSONArray jresult = new JSONArray(response);
  70.  
  71. jresult = json.getJSONArray("user");
  72. for (int i = 0; i < jresult .length(); i++)
  73. {
  74. JSONObject obj = jresult .getJSONObject(i);
  75. String username=obj.getString("username");
  76. int userid=obj.getInt("userid");
  77. }
  78.  
  79. if(result != null)
  80. {
  81. try
  82. {
  83. JSONObject jobj = result.getJSONObject("result");
  84.  
  85. String status = jobj.getString("status");
  86.  
  87. if(status.equals("true"))
  88. {
  89. JSONArray array = jobj.getJSONArray("user");
  90.  
  91. for(int x = 0; x < array.length(); x++)
  92. {
  93. HashMap<String, String> map = new HashMap<String, String>();
  94.  
  95. map.put("username", array.getJSONObject(x).getString("username"));
  96.  
  97. map.put("userid", array.getJSONObject(x).getString("userid"));
  98.  
  99.  
  100.  
  101. list.add(map);
  102. }
  103.  
  104. CalendarAdapter adapter = new CalendarAdapter(Calendar.this, list);
  105.  
  106. list_of_calendar.setAdapter(adapter);
  107. }
  108. }
  109. catch (Exception e)
  110. {
  111. e.printStackTrace();
  112. }
  113.  
  114. JSONArray jsonObj = new JSONArray(response);
  115. for(int i=0 ; i<jsonObj.length(); i++)
  116. {
  117. JSONObject json_Data = jsonObj.getJSONObject(i);
  118. String firstname = json_Data.getString("firstname");
  119. String lastname = json_Data.getString("lastname");
  120. String designation = json_Data.getString("designation");
  121.  
  122. JSONArray jsons1 = json_Data.getJSONArray("user");
  123. for (int j = 0; j < jsons1.length(); j++) {
  124.  
  125. JSONObject jsonss = jsons1.getJSONObject(j);
  126. String username = jsonss.getString("username");
  127. String userid = jsonss.getString("userid");
  128. }
  129.  
  130. }
  131. }catch (JSONException e) {
  132. Log.d("Failure","Dude I have failed");
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement