JSONassert

a Skyscreamer project


Quick Start

To use, download and build the JAR or add the following to your project's pom.xml:

<dependency>
  <groupId>org.skyscreamer</groupId>
  <artifactId>jsonassert</artifactId>
  <version>1.5.1</version>
</dependency>

Syntax is simple, and similar to JUnit Assert:

JSONAssert.assertEquals(expectedJSON, actualJSON, strictMode);

Add JSONassert tests within existing JUnit tests, just like you would add a standard Assert:

@Test
public void testGetUser() {
  Assert.assertTrue(_restService.isEnabled());
  String result = _restService.get("/user/123.json");
  JSONAssert.assertEquals("{id:123,name:\"Joe\"}", result, false);
}

It is recommended that you leave strictMode off, so your tests will be less brittle. Turn it on if you need to enforce a particular order for arrays, or if you want to ensure that the actual JSON does not have any fields beyond what's expected.