Following is a part of my json array
{
"format_file_name": [
"/client/compliance_format/payment_of_bonus_act_1965-ce32ec0ee2b94f819ffd2ffdb95ba439.pdf"
]
}
This is the part of my code while Im parsing it,
JSONArray format_file_name = innerJobj.getJSONArray("format_file_name");
if (format_file_name != null) {
for (int k = 0; k < format_file_name.length(); k++) {
JSONObject jsonObject1 = format_file_name.getJSONObject(i);
Iterator<String> keys = jsonObject1.keys();
while (keys.hasNext()) {
file = jsonObject1.getString(keys.next());
}
}
}
The value of format_file_name might be null some times.
In my code, i have already checked it it is null and in case if it is not null then Im parsing it and assigning it to a string called file
The problem is,
- When Im trying to parse the json array of null value, Im getting
Value null at format_file_name of type org.json.JSONObject$1 cannot be converted to JSONObject. How can I parse it only when its value is not equal to null? - Why my code doesnt work though I have checked for the condition of null and parsing it only if it is not null?