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
Asked
Active
Viewed 206 times
0

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

Ayan Bhattacharjee
- 105
- 2
- 10
-
1Please add your code as text and not images – Tamir Abutbul Mar 03 '19 at 20:46
2 Answers
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