spring-boot-starter-test depends on com.jayway.jsonpath:json-path, with the managed version for Spring Boot 4.1 being 2.10.0.
Support for Jackson 3 was introduced in json-path 3.0.0, notably with the addition of Jackson3MappingProvider and Jackson3JsonProvider, to be used in the json path configuration:
var configuration = com.jayway.jsonpath.Configuration
.builder()
.mappingProvider(new Jackson3MappingProvider(jsonMapper))
.jsonProvider(new Jackson3JsonProvider(jsonMapper))
.build();
This can then be used with JsonPathExpectationsHelper when constructing custom ResultMatchers:
ResultMatcher jsonPath(String expression, Matcher<? super T> matcher) {
JsonPathExpectationsHelper jsonPathHelper = new JsonPathExpectationsHelper(expression, configuration);
return result -> jsonPathHelper.assertValue(getContent(result), matcher);
}
Jackson 3 support is necessary due to limitations on the default JsonProvider (JsonSmartJsonProvider, see json-path/JsonPath#918, netplex/json-smart-v2#78).
Of course in the meantime we can just explicitly refer to the updated version:
<properties>
<json-path.version>3.0.0</json-path.version>
</properties>
spring-boot-starter-testdepends oncom.jayway.jsonpath:json-path, with the managed version for Spring Boot 4.1 being2.10.0.Support for Jackson 3 was introduced in json-path 3.0.0, notably with the addition of
Jackson3MappingProviderandJackson3JsonProvider, to be used in the json path configuration:This can then be used with JsonPathExpectationsHelper when constructing custom
ResultMatchers:Jackson 3 support is necessary due to limitations on the default
JsonProvider(JsonSmartJsonProvider, see json-path/JsonPath#918, netplex/json-smart-v2#78).Of course in the meantime we can just explicitly refer to the updated version: