Cannot invoke "com.google.gson.JsonElement.isJsonNull()" because the return value of "com.google.gson.JsonObject.get(String)" is null
I am trying to add a null check for my discord stats bot coded in java (with gson) It's giving me this error: Cannot invoke "com.google.gson.JsonElement.isJsonNull()" because the return value of "com.google.gson.JsonObject.get(String)" is null I have no idea why Here is my code, hopefully you can help me resolve this issue. public String getRank() { if (player.get("newPackageRank").isJsonNull()) { return "Non"; } else { return player.get("newPackageRank").getAsString(); } } Any help is appreciated! thanks
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.