skyscreamer / JSONassert

Write JSON unit tests in less code. Great for testing REST interfaces.
http://jsonassert.skyscreamer.org
Apache License 2.0
1k stars 197 forks source link

False negative when using kotlin raw strings #169

Closed vincent-paing closed 1 year ago

vincent-paing commented 1 year ago

When checking for nested object even though the return type is an object, the assertion fails as follows:

java.lang.AssertionError: textStyle
Expected: a JSON object
     got: {"textSize":12,"isBold":true}

A minimal reproducible code is as belows:

val expectedJson = """
            {
              "type": "text",
              "text": "Some Text",
              "textStyle": {
                "textSize": 12,
                "isBold": true
              }
            }
        """.trimIndent()

val actual = "{\"type\":\"text\",\"text\":\"Some Text\",\"textStyle\":\"{\\\"textSize\\\":12,\\\"isBold\\\":true}\"}"

JSONAssert.assertEquals(expectedJson, actual, false)
vincent-paing commented 1 year ago

My bad, it seems like my code is parsing it as string instead of object. closing this and apologies.