Guest User

Untitled

a guest
Apr 26th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. {
  2. COMENTARIOS: [
  3. {
  4. comentarios_id: "1053939",
  5. noticias_id: "284901",
  6. duelos_id: "0",
  7. respostas_id: "0",
  8. videos_id: "0",
  9. nome: "ludi",
  10. email: "email@email.com.br",
  11. ip: "186.212.2.226",
  12. comentario: "COMENTÁRIO",
  13. data_cadastro: "2018-04-03 09:34:00",
  14. status: "3",
  15. gostei: "67",
  16. naogostei: "143",
  17. resp: [ ]
  18. },
  19. {
  20. comentarios_id: "1053943",
  21. noticias_id: "284901",
  22. duelos_id: "0",
  23. respostas_id: "0",
  24. videos_id: "0",
  25. nome: "Andre",
  26. email: "email@email.com.br",
  27. ip: "187.120.224.30",
  28. comentario: "COMENTÁRIO",
  29. data_cadastro: "2018-04-03 09:45:01",
  30. status: "3",
  31. gostei: "236",
  32. naogostei: "114",
  33. resp: [
  34. {
  35. comentarios_id: "1053945",
  36. noticias_id: "284901",
  37. duelos_id: "0",
  38. respostas_id: "1053943",
  39. videos_id: "0",
  40. nome: "Usuário",
  41. email: "email@email.com.br",
  42. ip: "187.39.180.166",
  43. comentario: "COMENTÁRIO",
  44. data_cadastro: "2018-04-03 09:51:54",
  45. status: "3",
  46. gostei: "143",
  47. naogostei: "219",
  48. resp: [ ]
  49. },
  50. {
  51. comentarios_id: "1053987",
  52. noticias_id: "284901",
  53. duelos_id: "0",
  54. respostas_id: "1053943",
  55. videos_id: "0",
  56. nome: "Roberto, o Legítimo",
  57. email: "email@email.com.br",
  58. ip: "177.6.152.156",
  59. comentario: "COMENTÁRIO",
  60. data_cadastro: "2018-04-03 11:39:52",
  61. status: "3",
  62. gostei: "82",
  63. naogostei: "124",
  64. resp: [ ]
  65. },
  66. {
  67. comentarios_id: "1054030",
  68. noticias_id: "284901",
  69. duelos_id: "0",
  70. respostas_id: "1053943",
  71. videos_id: "0",
  72. nome: "xumbinho",
  73. email: "email@email.com.br",
  74. ip: "186.232.178.237",
  75. comentario: "COMENTÁRIO",
  76. data_cadastro: "2018-04-03 13:19:51",
  77. status: "3",
  78. gostei: "69",
  79. naogostei: "116",
  80. resp: [ ]
  81. }
  82. ]
  83. },
  84. {
  85. comentarios_id: "1053964",
  86. noticias_id: "284901",
  87. duelos_id: "0",
  88. respostas_id: "0",
  89. videos_id: "0",
  90. nome: "Celso",
  91. email: "email@email.com.br",
  92. ip: "177.97.174.169",
  93. comentario: "COMENTÁRIO",
  94. data_cadastro: "2018-04-03 10:38:06",
  95. status: "3",
  96. gostei: "41",
  97. naogostei: "116",
  98. resp: [ ]
  99. },
  100. {
  101. comentarios_id: "1054061",
  102. noticias_id: "284901",
  103. duelos_id: "0",
  104. respostas_id: "0",
  105. videos_id: "0",
  106. nome: "Usuário",
  107. email: "email@email.com.br",
  108. ip: "181.223.181.27",
  109. comentario: "COMENTÁRIO",
  110. data_cadastro: "2018-04-03 14:23:10",
  111. status: "3",
  112. gostei: "60",
  113. naogostei: "15",
  114. resp: [
  115. {
  116. comentarios_id: "1054173",
  117. noticias_id: "284901",
  118. duelos_id: "0",
  119. respostas_id: "1054061",
  120. videos_id: "0",
  121. nome: "bob",
  122. email: "email@email.com.br",
  123. ip: "92.59.121.38",
  124. comentario: "COMENTÁRIO",
  125. data_cadastro: "2018-04-03 17:19:32",
  126. status: "3",
  127. gostei: "5",
  128. naogostei: "106",
  129. resp: [ ]
  130. },
  131. {
  132. comentarios_id: "1054485",
  133. noticias_id: "284901",
  134. duelos_id: "0",
  135. respostas_id: "1054061",
  136. videos_id: "0",
  137. nome: "Usuário",
  138. email: "email@email.com.br",
  139. ip: "187.55.120.227",
  140. comentario: "COMENTÁRIO",
  141. data_cadastro: "2018-04-04 10:24:56",
  142. status: "3",
  143. gostei: "0",
  144. naogostei: "0",
  145. resp: [ ]
  146. }
  147. ]
  148. },
  149. {
  150. comentarios_id: "1054304",
  151. noticias_id: "284901",
  152. duelos_id: "0",
  153. respostas_id: "0",
  154. videos_id: "0",
  155. nome: "Jorge",
  156. email: "email@email.com.br",
  157. ip: "189.74.113.127",
  158. comentario: "COMENTÁRIO",
  159. data_cadastro: "2018-04-03 21:00:03",
  160. status: "3",
  161. gostei: "1",
  162. naogostei: "0",
  163. resp: [ ]
  164. },
  165. {
  166. comentarios_id: "1054382",
  167. noticias_id: "284901",
  168. duelos_id: "0",
  169. respostas_id: "0",
  170. videos_id: "0",
  171. nome: "Pé na cova",
  172. email: "email@email.com",
  173. ip: "168.194.160.137",
  174. comentario: "COMENTÁRIO",
  175. data_cadastro: "2018-04-03 23:45:29",
  176. status: "3",
  177. gostei: "1",
  178. naogostei: "0",
  179. resp: [ ]
  180. }
  181. ]
  182. }
  183.  
  184. JSONArray comentarios = jsonObj.getJSONArray("COMENTARIOS");
  185. for (int i = 0; i < comentarios.length(); i++) {
  186. JSONObject c = comentarios.getJSONObject(i);
  187. String nome = c.getString("nome");
  188. String comentario = c.getString("comentario");
  189.  
  190. HashMap<String, String> comentariotxt = new HashMap<>();
  191.  
  192. comentariotxt.put("nome", nome);
  193. comentariotxt.put("comentario", comentario);
  194.  
  195. JSONArray resp = c.getJSONArray("resp");
  196. if(resp.length() > 0){
  197. for (int j = 0; j < resp.length(); j++){
  198. JSONObject d = resp.getJSONObject(j);
  199. String respostaNome = d.getString("nome");
  200. String respostaComentario = d.getString("comentario");
  201. Log.d("respostaNome",respostaNome);
  202.  
  203. HashMap<String, String> respostatxt = new HashMap<>();
  204. respostatxt.put("respostaNome", respostaNome);
  205. respostatxt.put("respostaComentario", respostaComentario);
  206. comentarioList.add(respostatxt);
  207. }
  208. }
  209. comentarioList.add(comentariotxt);
  210. }
  211.  
  212. try {
  213. JSONObject jsonObject1 = new JSONObject("{n" +
  214. "t"COMENTARIOS": [{n" +
  215. "tt"comentarios_id": "1053939",n" +
  216. "tt"noticias_id": "284901",n" +
  217. "tt"duelos_id": "0",n" +
  218. "tt"respostas_id": "0",n" +
  219. "tt"videos_id": "0",n" +
  220. "tt"nome": "ludi",n" +
  221. "tt"email": "email@email.com.br",n" +
  222. "tt"ip": "186.212.2.226",n" +
  223. "tt"comentario": "COMENTÁRIO",n" +
  224. "tt"data_cadastro": "2018-04-03 09:34:00",n" +
  225. "tt"status": "3",n" +
  226. "tt"gostei": "67",n" +
  227. "tt"naogostei": "143",n" +
  228. "tt"resp": []n" +
  229. "t}]n" +
  230. "}");
  231. JSONArray jsonArray = jsonObject1.getJSONArray("COMENTARIOS");
  232. for (int i = 0; i < jsonArray.length(); i++) {
  233. JSONObject jsonObject = jsonArray.getJSONObject(i);
  234. String comentarios_id = jsonObject.get("noticias_id").toString();
  235. System.out.println("----comentarios_id---" + comentarios_id);
  236. }
  237.  
  238. } catch (JSONException e) {
  239. e.printStackTrace();
  240. System.out.println("----comentarios_id---exc--" + e);
  241. }
Add Comment
Please, Sign In to add comment