Enhance JsonPathExpectationsHelper to allow use of JSONPath Configuration #31651
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
JSONPath supports using a
Configuration
to customize its behavior, or to pass aJsonProvider
that in turn enables parsing to higher level objects.JsonPathExpectationsHelper
manages JSONPath internally without any option to change this, and effectively usesConfiguration.defaultConfiguration()
that supports parsing to basic types only.We should open up
JsonPathExpectationsHelper
to make it possible to pass or customize theConfiguration
to use, and that would enable decoding to higher level objects. The helper does have a method to read to a targetClass
but it won't work for anything more than basic types, and we add another that takesParameterizedTypeReference
.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 enableWebTestClient
to transparently pass aConfiguration
toJsonPathExpecationsHelper
. It will also make it possible for MockMvc users to create a customResultMatcher
instance that delegates toJsonPathExpectationsHelper
. We can separately explore some such built-in option for MockMvc.The text was updated successfully, but these errors were encountered: