Skip to content

Support generics (and POJO object mapper) for jsonPath ResultMatcher #27486

Closed as not planned
@FichteFoll

Description

@FichteFoll

Affects: 2.4.1


When asserting JSON content in a MockMvc, the provided MockMvcResultMatchers.jsonPath functions support automatic type deduction or an explicit Class<T> parameter (via #23141), but there is an additional version in JsonPath that supports a TypeRef generic and is not exposed. It would be very useful if it was, especially for containsInAnyOrder assertions of POJOs.

For this purpose, it would furthermore be useful if a POJO mapper was configured since afaics it isn't currently.

JsonPath Documentation

var configuration = Configuration.defaultConfiguration().mappingProvider(new JacksonMappingProvider());
var document = JsonPath.using(configuration).parse(JSON_DOCUMENT);
var typeRef = new TypeRef<List<Book>>() {};
List<String> titles = document.read("$.store.book", typeRef);

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: testIssues in the test modulestatus: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions