Guest User

Untitled

a guest
Dec 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. " {"clientes": " +
  2. " [" +
  3. " { "idClientesT": 1," +
  4. " "tipo":"s"," +
  5. " "nome":"Carlos"" +
  6. " }," +
  7. " { "idClientesT": 2," +
  8. " "tipo":"s"," +
  9. " "nome":"Rogério"" +
  10. " }" +
  11. " ]" +
  12. "}";
  13.  
  14. try {
  15.  
  16. JSONObject clientes = new JSONObject(jsonCli);
  17. JSONArray arrayPlanetas = clientes.getJSONArray("clientes");
  18.  
  19. for (int i = 0; i < arrayPlanetas.length(); i++) {
  20.  
  21. JSONObject cliente = arrayPlanetas.getJSONObject(i);
  22.  
  23. Log.d("idClientesT", cliente.getString("idClientesT"));
  24. Log.d("tipo", cliente.getString("tipo"));
  25. Log.d("nome", cliente.getString("nome"));
  26.  
  27. }
  28.  
  29. } catch (JSONException e) {
  30. e.printStackTrace();
  31. }
  32.  
  33. @Override
  34. protected void onCreate(Bundle savedInstanceState) {
  35. super.onCreate(savedInstanceState);
  36. setContentView(R.layout.form);
  37.  
  38. clientes(jsonClientes);
  39.  
  40. }
  41.  
  42. {"clientes":[{"idClientesT":"1","tipo":"s","nome":"Carlos"},{"idClientesT":"2","tipo":"s","nome":"Rogério"}]}
  43.  
  44. JSONArray arrayPlanetas = clientes.getJSONArray("clientes");
  45.  
  46. .getJSONArray("clientes");
  47.  
  48. .getJSONArray(url);
Add Comment
Please, Sign In to add comment