File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-webapp/src/main/java/com/azure/spring/sample/aad/utils Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 66import com .fasterxml .jackson .core .JsonProcessingException ;
77import com .fasterxml .jackson .databind .ObjectMapper ;
88import com .fasterxml .jackson .databind .SerializationFeature ;
9+ import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
910import org .slf4j .Logger ;
1011import org .slf4j .LoggerFactory ;
1112import org .springframework .security .oauth2 .client .OAuth2AuthorizedClient ;
1213
1314public class JsonMapper {
1415 private static final Logger LOGGER = LoggerFactory .getLogger (JsonMapper .class );
1516 private static final ObjectMapper MAPPER = new ObjectMapper ().enable (SerializationFeature .INDENT_OUTPUT );
17+ static {
18+ MAPPER .registerModule (new JavaTimeModule ());
19+ }
1620
17- public static final String toJsonString (OAuth2AuthorizedClient authorizedClient ) {
18- String clientJsonString = "Json String for OAuth2AuthorizedClient" ;
19-
21+ public static String toJsonString (OAuth2AuthorizedClient authorizedClient ) {
22+ String clientJsonString ;
2023 try {
2124 clientJsonString = MAPPER .writeValueAsString (authorizedClient );
2225 } catch (JsonProcessingException e ) {
23- LOGGER .warn ("Error with transfer OAuth2AuthorizedClient to Json" );
26+ LOGGER .warn ("Error when transfer OAuth2AuthorizedClient to Json" , e );
2427 clientJsonString = "Fail to generate Json String of current OAuth2AuthorizedClient" ;
2528 }
26-
2729 LOGGER .info (clientJsonString );
2830 return clientJsonString ;
2931 }
You can’t perform that action at this time.
0 commit comments