Hamcrest matchers for comparing JSON documents, backed by the JSONassert library. The code is released under the MIT license. Supports Java 8 or later.
To install from Maven Central:
<dependency>
<groupId>uk.co.datumedge</groupId>
<artifactId>hamcrest-json</artifactId>
<version>0.2</version>
</dependency>
import static uk.co.datumedge.hamcrest.json.SameJSONAs.*;
assertThat(
"{\"age\":43, \"friend_ids\":[16, 52, 23]}",
sameJSONAs("{\"friend_ids\":[52, 23, 16]}")
.allowingExtraUnexpectedFields()
.allowingAnyArrayOrdering());