Skip to content

Commit

Permalink
Merge pull request #12465 from piyumaldk/master
Browse files Browse the repository at this point in the history
[Public] [Fix] Fix JsonPrimitive casting exception
  • Loading branch information
piyumaldk committed Jun 14, 2024
2 parents a5905ad + d48a673 commit c9e3d9c
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 c9e3d9c

Please sign in to comment.