Consume Json object nested inside another object using Volley

1

Dear liking in greeting you, I am trying to consume an object Json through Volley using Android , however I only get to consume a part of Json . I am new to this, I hope you can help me, Thanks in advance.

    
asked by Cristian Bossardt 27.09.2018 в 19:57
source

2 answers

0

You can access with:

JSONObject contactJObject = jsonObject.getJSONObject("contact");
System.out.println(contactObject.getString("mobile"));
    
answered by 27.09.2018 в 20:07
0

The data that you were able to obtain is inside a json object but the data that you point out is also inside an object called "contact":

Get the object "contact" and then its properties:

JSONObject jsonObjectContact = jsonObject.getJSONObject("contact");

Toast.makeText(getApplicationContext(), "Respuesta"+
jsonObject.getString("id") + " " +
jsonObject.getString("name") + " " +
jsonObject.getString("email") + " " +
jsonObject.getString("gender") + " " +
jsonObjectContact.getString("mobile") + " " +
jsonObjectContact.getString("home") + " " +
jsonObjectContact.getString("office"), Toast.LENGTH_LONG).show();
    
answered by 28.09.2018 в 01:26