Rank 2: Process
I am trying to get name from logged In user Session and display it on a textview from the following code snippet.
private void getUserName(){ client = new Client(requireActivity()) .setEndpoint(endpoint) .setProject(project); account = new Account(client); account.getSession("current", new CoroutineCallback<>((result, error)-> { if (error != null) { error.printStackTrace(); }else{ // pass `result` in to a json object try { JSONObject jsonObject = new JSONObject(String.valueOf(result)); //get parameter "name" from the json object String name = jsonObject.getString("name"); // pass the name parameter into textview binding.userNameDisplay.setText(name); } catch (JSONException e) { e.printStackTrace(); } } } )); }I get this exception Error
org.json.JSONException: Value Session(id of type java.lang.String cannot be converted to JSONObject