简体   繁体   中英

How to skip jackson "unwrap-root-value" for certain post request?

I am using spring.jackson.deserialization.unwrap-root-value=true to unwrap all my request.I tried to use spring actuator to change the log level but am getting "JSON parse error: Root name 'configuredLevel' does not match" exception .

For this jackson is expecting the root name but it is a spring-endpoint.

How can I skip jackson unwrap for this request alone or any other we can do that?

URI:http://localhost:8080/test/services/v1/loggers/com.rathna

This is my reponse for actuator endpoint.

{
    "timestamp": 1548406670397,
    "status": 400,
    "error": "Bad Request",
    "exception": "org.springframework.http.converter.HttpMessageNotReadableException",
    "message": "JSON parse error: Root name 'configuredLevel' does not match expected ('Map') for type [map type; class java.util.Map, [simple type, class java.lang.String] -> [simple type, class java.lang.String]]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Root name 'configuredLevel' does not match expected ('Map') for type [map type; class java.util.Map, [simple type, class java.lang.String] -> [simple type, class java.lang.String]]\n at [Source: java.io.PushbackInputStream@8b6500; line: 2, column: 2]",
    "path": "test/services/v1/loggers/com.rathna"
}

Need to process all type of request.

您可以将其用作请求正文{"Map": {"configuredLevel": "INFO"}} ,这将起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM