Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package json;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- public class Main {
- public static void main(String[] args)
- {
- String fuente = JsonUtiles.leer("prueba");
- try
- {
- JSONObject jo = new JSONObject(fuente);
- boolean success = jo.getBoolean("success");
- int code = jo.getInt("code");
- String nombre = jo.getString("nombre");
- JSONObject data = jo.getJSONObject("data");
- JSONObject message = jo.getJSONObject("message");
- JSONObject error = message.getJSONObject("error");
- String mensaje = error.getString("mensaje");
- System.out.println(mensaje);
- String text = message.getString("text");
- System.out.println(text);
- int status = data.getInt("status");
- System.out.println(status);
- JSONArray array = jo.getJSONArray("servicios");
- for (int i=0;i<array.length();i++)
- {
- JSONObject jsonObject = array.getJSONObject(i);
- System.out.println(jsonObject.getString("service_text"));
- }
- JSONArray etiquetas = jo.getJSONArray("etiquetas");
- for (int i=0;i<etiquetas.length();i++)
- {
- String etiqueta = etiquetas.getString(i);
- System.out.println(etiqueta);
- }
- //String text = jo.getString("text");
- }
- catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement