Skip to main content
Version: 5.3

JSON

Basic matchers​

MatcherDescriptionTargets
shouldBeValidJsonverifies that a given string parses to valid jsonMultiplatform
shouldBeJsonObjectasserts that a string is a valid JSON objectMultiplatform
shouldBeJsonArrayasserts that a string is a valid JSON arrayMultiplatform

Content-based matching​

For more details, see here or follow matcher-specific links below

MatcherDescriptionTargets
shouldEqualJsonVerifies that a String matches a given JSON structure.Multiplatform
shouldEqualSpecifiedJsonVerifies that a String matches a given JSON structure, but allows additional unspecified properties.Multiplatform
shouldContainJsonKeyVerifies that a String is JSON, and contains a given JSON pathJVM
shouldContainJsonKeyValueVerifies that a String is JSON, and contains a given JSON path with the specified valueJVM
shouldMatchJsonResourceVerifies that a String is matches the JSON content of a given test resourceJVM

Schema validation​

MatcherDescriptionTargets
shouldMatchSchemaValidates that a String or kotlinx.serialization.JsonElement matches a JsonSchema. See description below for details on constructing schemas.Multiplatform