Skip to content

Upgrade to Json Path 3.0.0 #50786

Description

@gbaso

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: team-onlyAn issue that's best handled directly by the team rather than a community contribution.type: dependency-upgradeA dependency upgrade

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions