spring-framework / org.springframework.test.web.servlet.result / ContentResultMatchers / json

json

open fun json(jsonContent: String): ResultMatcher

Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).

Parameters

jsonContent - the expected JSON content

Since
4.1

open fun json(jsonContent: String, strict: Boolean): ResultMatcher

Parse the response content and the given string as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting.

Can compare in two modes, depending on strict parameter value:

Use of this matcher requires the JSONassert library.

Parameters

jsonContent - the expected JSON content

strict - enables strict checking

Since
4.2