how do i access specific information in json?

Use some JSON library, e.g. org.json to parse the string first. In your case the code to get the token would like something like this:

import org.json.*;
    
try
{
    String data = response.body().string();
    JSONObject jsonData = new JSONObject(data);
    
    String token = jsonData.getString("token");
    Log.e("response", token);
}
catch (JSONException e)
{
     Log.e("JSON Exception", e);
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top