diff --git a/pom.xml b/pom.xml index c9e6a24..51c9794 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,16 @@ commons-io 2.7 + + com.fasterxml.jackson.core + jackson-core + 2.13.1 + + + com.fasterxml.jackson.core + jackson-databind + 2.13.1 + com.google.guava guava diff --git a/src/main/java/com/botdarr/api/lidarr/LidarrApi.java b/src/main/java/com/botdarr/api/lidarr/LidarrApi.java index c9861c2..9d549ca 100644 --- a/src/main/java/com/botdarr/api/lidarr/LidarrApi.java +++ b/src/main/java/com/botdarr/api/lidarr/LidarrApi.java @@ -8,6 +8,8 @@ import com.botdarr.clients.ChatClientResponseBuilder; import com.botdarr.commands.CommandContext; import com.botdarr.connections.ConnectionHelper; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.*; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -270,11 +272,15 @@ private ChatClientResponse addArtist(LidarrArtist lidarrArtist) { try (CloseableHttpClient client = HttpClientBuilder.create().build()) { HttpPost post = new HttpPost(getApiUrl(SonarrUrls.ARTIST_BASE)); post.addHeader("content-type", "application/json"); - String json = new Gson().toJson(lidarrArtist, LidarrArtist.class); + + ObjectMapper mapper = new ObjectMapper(); + //lidarr for some reason doesn't support raw unicode characters in json parsing (since they should be allowed), so we escape them here + mapper.getFactory().configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true); + String json = mapper.writeValueAsString(lidarrArtist); post.setEntity(new StringEntity(json)); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Client request=" + post.toString()); + LOGGER.debug("Client request=" + post); LOGGER.debug("Client data=" + (json)); } diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index 8044406..fb467b1 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -5.2.1 \ No newline at end of file +5.2.2 \ No newline at end of file