JSONassert is a project to “Write JSON unit tests in less code. Great for testing REST interfaces.” The following is maven dependency of JSONassert:
<dependency> <groupId>org.skyscreamer</groupId> <artifactId>jsonassert</artifactId> <version>1.3.0</version> </dependency>
To test whether 2 JSON objects are same or not, do the following:
JSONAssert.assertEquals(expectedJson, actualJson, JSONCompareMode.NON_EXTENSIBLE);
NON_EXTENSIBLE is the most commonly used compare mode of 4. You can check javadoc to find out how they function.