greg woodfill

about | github | linkedin

Kotlin JSON Assertions

I’ve just released a new project called Kotlin Json Assert on GitHub. It is a library for asserting JSON with Kotlin, that uses the style of the Kluent style assertions for JSON project. It is a thin wrapper over the excellent JSONAssert library.

Sample Usage

// strict checking is off by default
 """{"firstName": "Bob", "lastName":"Smith"}""" shouldEqualJson """{ "firstName": "Bob" }"""
"{}" shouldNotEqualJson """{"firstName":"Bob"}"""
// strict checking can be applied with `should strictly equal`
"""{"firstName": "Bob"}""" shouldStrictlyEqualJson """{ "firstName": "Bob" }"""