Skip to content

Commit

Permalink
#3231: Add method to safely parse JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten committed Nov 12, 2020
1 parent 2b93e9c commit 1ca385d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/mil/dds/anet/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ private static void internalSanitizeJsonForHtml(JsonNode jsonNode) {
}
}

public static JsonNode parseJsonSafe(String inputJson) throws JsonProcessingException {
final String sanitizedJson = Utils.sanitizeJson(inputJson);
return sanitizedJson == null ? null : mapper.readTree(sanitizedJson);
}

public static String trimStringReturnNull(String input) {
if (input == null) {
return null;
Expand Down

0 comments on commit 1ca385d

Please sign in to comment.