Skip to content

Enhance JsonPathExpectationsHelper to allow use of JSONPath Configuration #31651

Closed
@rstoyanchev

Description

@rstoyanchev

JSONPath supports using a Configuration to customize its behavior, or to pass a JsonProvider that in turn enables parsing to higher level objects. JsonPathExpectationsHelper manages JSONPath internally without any option to change this, and effectively uses Configuration.defaultConfiguration() that supports parsing to basic types only.

We should open up JsonPathExpectationsHelper to make it possible to pass or customize the Configuration to use, and that would enable decoding to higher level objects. The helper does have a method to read to a target Class but it won't work for anything more than basic types, and we add another that takes ParameterizedTypeReference.

This will not fully address #27486 and #31423 since MockMvc there is no good way to re-use a custom Configuration in a static API. However, it will enable WebTestClient to transparently pass a Configuration to JsonPathExpecationsHelper. It will also make it possible for MockMvc users to create a custom ResultMatcher instance that delegates to JsonPathExpectationsHelper. We can separately explore some such built-in option for MockMvc.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions