I have the following code:
JSONObject student2 = new JSONObject();
try {
student2.put("name", "NAME OF STUDENT2");
System.out.println(student2.get("name"));
System.out.println(student2.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
I was just trying to create an JSONObject and extract the "name" value from it.
But the two "System.out.println" commands returns null. I expect the string "NAME OF STUDENT2" as a result.
What I was doing wrong?
from Getting null when using getString with JSONObject class on Android
No comments:
Post a Comment