Verificando se existe subObject em JSON
Estou verificando se existe um objeto em uma string JSON usando isto:
JSONObject json = null;
try {
json = new JSONObject(myJsonString);
} catch (JSONException e) { e.printStackTrace(); }
if(json.has("myObject")) System.out.println("EXISTS");
else System.out.println("DOESN'T EXIST");
O problema aparece quando tento verificar se existe um objeto secundário. por exemplo:
...,"queue":{"building":{"q0":{"id":177779,...
Fila sempre existe econstrução também, masq0 nem sempre está lá. Então, como posso verificar a existência deq0? E existe uma maneira de verificar isso usando a biblioteca Gson?
Agradeço antecipadamente!