0
I have a program that takes reports from a system, I’m including one more table in the program. The data that is read, comes from a array but sometimes it is empty, and when it gives this the program gives error.
I put an if to check if the variable is null
, because if it is it will take the value of another table.
But when I debugged he accused error:
Source not found
JSONObject js2 = js.getJSONObject("cliente").getJSONArray("enderecoList").getJSONObject(0);
on that line and the program stops running.
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject js = jsonArray.getJSONObject(i);
JSONObject js2 = js.getJSONObject("cliente").getJSONArray("enderecoList").getJSONObject(0);
JSONObject js3;
if (js2 == null){
js3 = js.getJSONObject("unidade").getJSONObject("municipio");
} else {
js3 = js2.getJSONObject("municipio");
}
I tried to use the method, but it points out that it is incompatible and that a variable of type String is needed.
– Leticia Fatima