Java loop throug gson JsonElement

Java
final JsonObject jsonObject = GSON.toJsonTree(<Object>).getAsJsonObject();
for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
    System.out.println("Key = " + entry.getKey() + " Value = " + entry.getValue() );
}
Source

Also in Java: