JSON
Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →
Para usar estos matchers, añade testImplementation("io.kotest:kotest-assertions-json:<version>") a tu build.
Comparadores básicos
| Matcher | Description | Targets |
|---|---|---|
shouldBeValidJson | verifies that a given string parses to valid json | Multiplatform |
shouldBeJsonObject | asserts that a string is a valid JSON object | Multiplatform |
shouldBeJsonArray | asserts that a string is a valid JSON array | Multiplatform |
Comparación basada en contenido
Para más detalles, consulta aquí o sigue los enlaces específicos de cada comparador a continuación
| Matcher | Description | Targets |
|---|---|---|
| shouldEqualJson | Verifies that a String matches a given JSON structure. | Multiplatform |
| shouldEqualSpecifiedJson | Verifies that a String matches a given JSON structure, but allows additional unspecified properties. | Multiplatform |
| shouldContainJsonKey | Verifies that a String is JSON, and contains a given JSON path | JVM |
| shouldContainJsonKeyValue | Verifies that a String is JSON, and contains a given JSON path with the specified value | JVM |
| shouldMatchJsonResource | Verifies that a String is matches the JSON content of a given test resource | JVM |
Validación de esquema
| Matcher | Description | Targets |
|---|---|---|
| shouldMatchSchema | Validates that a String or kotlinx.serialization.JsonElement matches a JsonSchema. See description below for details on constructing schemas. | Multiplatform |