Assert field by field is annoying and sometimes we want to compare the whole result.
Something like
val request = ChargeRequest(listOf(ItemRequest(1, "test", 1)), MetadataRequest("0001", ""))
val exectedJson = """
{"metadataRequest":{"custom_id":"0001", "notification_url":""},"items":[{"amount":1,"name":"test","value":1}]}
""".trimIndent()
JSONAssert.assertEquals(request.toJsonString, exectedJson, true)
In JSONAssert, there is the strict configuration. When true all fields must be equal and have the same property count. When false the fields that exist on the expectations must match, but extra fields are allowed.
For example:
object a:
{
"foo": "bar",
"bar": "foo"
}
object b:
In strict mode: a != b
Strict mode false: a = b
Assert field by field is annoying and sometimes we want to compare the whole result.
Something like
In JSONAssert, there is the strict configuration. When true all fields must be equal and have the same property count. When false the fields that exist on the expectations must match, but extra fields are allowed.
For example:
object a:
object b:
In strict mode: a != b
Strict mode false: a = b