I am facing an issue while trying to retrieve value from JSONObject. I've spent an hour researching the solution, but non of suggestions work in other posts or anywhere else.
When I run above code on emulator, it throws error and I am able to catch it.
JSONException: No value for property
However If I put a breakpoint in try block and run the app, with Android Studio's Evaluate Expression tool I am able to get non empty value with the same code, and it does not throw exception. So the initial JSONObject userInfo definitely contains the data I am trying to get, and it works if I run it in debug mode by hands.
Here is my code.
String value = "";
try {
JSONObject obj = userInfo.getJSONObject("data");
value = obj.getString(param);
} catch (JSONException e) {
e.printStackTrace();
}
Emulator is configured with standard Nexus 5 configs with android studio.