Skip to content

Commit

Permalink
Jackson allow_backlash_escaping_any_character
Browse files Browse the repository at this point in the history
  • Loading branch information
justodiaz committed Mar 2, 2024
1 parent 1f2840e commit 2836bf9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/example/HTTPJsonRequestClient.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.example;

import com.fasterxml.jackson.core.json.JsonReadFeature;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.http.HttpClient;
Expand Down Expand Up @@ -33,8 +34,10 @@ public <T> Optional<T> send(HttpRequest httpRequest, Class<T> type) {
private <T> Function<String, T> mapJsonResponseToType(Class<T> type) {
return (String string) -> {
try {
return new ObjectMapper()
return JsonMapper.builder()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true)
.build()
.readValue(string, type);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down

0 comments on commit 2836bf9

Please sign in to comment.