Skip to content

Commit

Permalink
[FIX] objectmapper to parse json with value containing backslash
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Mar 8, 2024
1 parent c152000 commit 411cc3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,11 +25,14 @@ public void configureMessageConverters(final List<HttpMessageConverter<?>> 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());
}
Expand Down

0 comments on commit 411cc3f

Please sign in to comment.