Showing
1 changed file
with
5 additions
and
2 deletions
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonInclude; | ||
| 3 | import com.fasterxml.jackson.core.JsonProcessingException; | 4 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 5 | +import com.fasterxml.jackson.databind.DeserializationFeature; | ||
| 4 | import com.fasterxml.jackson.databind.ObjectMapper; | 6 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | import com.fasterxml.jackson.databind.PropertyNamingStrategy; | 7 | import com.fasterxml.jackson.databind.PropertyNamingStrategy; |
| 6 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; | 8 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| ... | @@ -35,8 +37,6 @@ public class PayServiceClient { | ... | @@ -35,8 +37,6 @@ public class PayServiceClient { |
| 35 | 37 | ||
| 36 | private final BusinessConfig businessConfig; | 38 | private final BusinessConfig businessConfig; |
| 37 | 39 | ||
| 38 | - private final ObjectMapper objectMapper; | ||
| 39 | - | ||
| 40 | @Value("${payment.client-id:Order0001}") | 40 | @Value("${payment.client-id:Order0001}") |
| 41 | private String clientId; | 41 | private String clientId; |
| 42 | 42 | ||
| ... | @@ -48,6 +48,9 @@ public class PayServiceClient { | ... | @@ -48,6 +48,9 @@ public class PayServiceClient { |
| 48 | ThirdPartyPayInformRequestDto jsonData = buildRequestData(payRequestDto, requestDate); | 48 | ThirdPartyPayInformRequestDto jsonData = buildRequestData(payRequestDto, requestDate); |
| 49 | String jsonDataString; | 49 | String jsonDataString; |
| 50 | try { | 50 | try { |
| 51 | + ObjectMapper objectMapper = new ObjectMapper(); | ||
| 52 | + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
| 53 | + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | ||
| 51 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); | 54 | objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); |
| 52 | jsonDataString = objectMapper.writeValueAsString(jsonData); | 55 | jsonDataString = objectMapper.writeValueAsString(jsonData); |
| 53 | } catch (JsonProcessingException e) { | 56 | } catch (JsonProcessingException e) { | ... | ... |
-
Please register or login to post a comment