Reputation: 23
I have an object which needs 4 parameters to set the values from a JSONObject
. But, when I call get(String name)
from JSONObject
it has 3 values, so that throws a JSONException
. Here is an example:
"JSON":{
"aaa":"111",
"bbb":"111",
"ddd":"111"
}
How can set null
for a value if the JSON key is non-existant.. not using GSON
Upvotes: 2
Views: 1037
Reputation: 4641
like this:
if (jsonObject.has("aaa") {
this.aaa = jsonObject.getString("aaa");
}
Upvotes: 1