0

I am trying to get JSON data from an api which generates the user name and password but I am failing to do so, please help Postman output

Android Studio function andLogcat

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50

2 Answers2

0

Your API returns JSON Object instead of JSONArray.

Check difference between those two : JSON Object vs JSONArray

Though you can work with JSONObject too, just do below:

String value =  jsonObject.getString("key")

In case of you are using Volley, then by default Volley returns success response by parsing it in JSONObject. So jsonObject would be replaced by response.

Swr7der
  • 849
  • 9
  • 28
0

Your API returns JSON Object instead of JSONArray. Parse your response directly in JSONObject instead of JSONArray and retrieve id and password from it.

JSONObject jsonObject= new JSONObject(response);
String id=jsonObject.getString("u_name");
String passworf=jsonObject.getString("u_pass");
Ved
  • 1,035
  • 14
  • 28