I would like to iterate through the big wrapping JsonObject
with Gson. My final aim is to get an ArrayList
of all existing three digit code
You can use entrySet to iterate over the members of the outermost JsonObject
.
JsonObject object;
ArrayList<Integer> codes = new ArrayList<Integer>();
for (Map.Entry<String,JsonElement> entry : object.entrySet()) {
JsonArray array = entry.getValue().getAsJsonObject().getAsJsonArray("unterfeld");
for (JsonElement codeHolder : array) {
codes.add(codeHolder.getAsJsonObject().getAsJsonPrimitive("code").getAsInt());
}
}