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


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


 
    
     
    
    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.
 
    
    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");
