Skip to content

Commit

Permalink
Fix JsonPrimitive casting exception
Browse files Browse the repository at this point in the history
  • Loading branch information
piyumaldk committed Jun 11, 2024
1 parent 328322c commit d48a673
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,14 @@ public static void addApplicationKey(String username, Application application, A
JsonObject jsonObject = gson.fromJson(additionalProperties, JsonObject.class);
Set<String> keysSet = jsonObject.keySet();
for (String key : keysSet) {
if (jsonObject.getAsJsonPrimitive(key).isNumber()) {
jsonObject.addProperty(key, String.valueOf(jsonObject.getAsJsonPrimitive(key).getAsLong()));
if (jsonObject.get(key).isJsonPrimitive()) {
if (jsonObject.getAsJsonPrimitive(key).isNumber()) {
jsonObject.addProperty(key, String.valueOf(jsonObject.getAsJsonPrimitive(key).getAsLong()));
} else {
jsonObject.addProperty(key, jsonObject.getAsJsonPrimitive(key).getAsString());
}
} else {
jsonObject.addProperty(key, jsonObject.getAsJsonPrimitive(key).getAsString());
jsonObject.addProperty(key, jsonObject.get(key).toString());
}
}
jsonParamObj.addProperty(APIConstants.JSON_ADDITIONAL_PROPERTIES, jsonObject.toString());
Expand Down

0 comments on commit d48a673

Please sign in to comment.