Json nested Objects check if null
问题 consider the following json { "sub1":{ "name":"Name-sub1", "sub11":{ "name":"Name-sub11", "sub111":{ "name":"Name-sub111", ... }, .. }, ... }, ... } I now want to fetch the inner name Element (Name-sub111) in java (it's a io.vertx.core.json.JsonObject) object.getJsonObject("sub1").getJsonObject("sub11").getJsonObject("sub111").getString("name") But I'm not sure if sub1 or sub11 or sub111 even exist - so I always need to check for null if(object.getJsonObject("sub1") != null && object