My app fetches JSON response from server. The response string has multiple rows and columns. I need to print this in java.
Here is my JSON response :
[
{
"name": "name2",
"id": "99",
"email": "ad@e.com"
},
{
"name": "zca",
"id": "96",
"email": "as2c2@d.d",
}
]
this is java part :
OkHttpClient client = new OkHttpClient();
String url = ServerConstants.BROWSE_URL;
//String url = "https://reqres.in/api/users?page=2";
Request request = new Request.Builder()
.url(url)
.build();
client.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException e)
{
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException
{
if (response.isSuccessful())
{
final String myResponse = response.body().string();
//System.out.println(Arrays.asList(new BundleFunctions().MakeArrayListFormJSON(myResponse)));
bundle = new BundleFunctions().MakeBundleFromJSON(myResponse);
//System.out.println("this is size ------- "+bundle.size());
//System.out.println("this is response ------ "+myResponse);
Browse.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
tv.setText(myResponse);
Set<String> keys = bundle.keySet();
for(String key : keys)
{
Object o = bundle.get(key);
}
}
});
}
}
});
I need a print on each person like this in java :
(Person number is according to array index FCFS)
Person 1 - Name : name2 , id : 99 , email : ad@e.com
Person 2 - Name : zca , id : 96 , email : as2c2@d.d
Please show me the simplest way to do this