From 411cc3fb7045d09ffa9b3ef3add9723c14b57434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Fri, 8 Mar 2024 22:49:39 +0900 Subject: [PATCH] [FIX] objectmapper to parse json with value containing backslash --- .github/workflows/backend-ci.yml | 12 +----------- .../java/com/twtw/backend/config/web/WebConfig.java | 9 +++++++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 67f495da..e9da9017 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -40,17 +40,7 @@ jobs: echo "${{ secrets.STORAGE_JSON }}" > src/test/resources/engaged-shade-405207-b8ba9bb8a30f.json echo "${{ secrets.STORAGE_JSON }}" > src/main/resources/engaged-shade-405207-b8ba9bb8a30f.json - - name: Set File Permissions - run: | - chmod 644 src/test/resources/application-env.yml - chmod 644 src/main/resources/application-env.yml - chmod 644 src/test/resources/twtw_firebase_key.json - chmod 644 src/main/resources/twtw_firebase_key.json - chmod 644 src/test/resources/engaged-shade-405207-b8ba9bb8a30f.json - chmod 644 src/main/resources/engaged-shade-405207-b8ba9bb8a30f.json - chmod +x gradlew - find src - + - run: chmod +x gradlew - run: ./gradlew build - run: ./gradlew jib diff --git a/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java b/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java index 92fecc15..8540816b 100644 --- a/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/web/WebConfig.java @@ -1,12 +1,14 @@ package com.twtw.backend.config.web; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; - +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; @@ -23,11 +25,14 @@ public void configureMessageConverters(final List> conve super.configureMessageConverters(converters); } - private ObjectMapper objectMapper() { + @Bean + @Primary + public ObjectMapper objectMapper() { return new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true) + .configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true) .setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE) .registerModule(new JavaTimeModule()); }