Last active
January 9, 2023 23:54
-
-
Save ashwinrs/75bc701c2576d1f42087b539404a7a7b to your computer and use it in GitHub Desktop.
Iterate over elements in a JSON using GSON in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final JsonObject jsonObject = GSON.toJsonTree(<Object>).getAsJsonObject(); | |
for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { | |
System.out.println("Key = " + entry.getKey() + " Value = " + entry.getValue() ); | |
} |
Nevermind. I had to add .getAsJsonObject() as it was JsonElement
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In java i am getting an error over .entrySet()