JSONAssert is a Java library for simplifying JUnit tests which need to compare complex JSON structures.
JSONAssert is an open-source library aimed at simplifying JUnit tests which need to compare complex JSON structures.
The tests contain simple assertions which resemble string comparisons, e.g.:
final String actual = ...; // get JSON string from a REST endpoint
final String expected =
"{success:true, items: [{id:4711, name:\"Cat\"}, {id:1147,name:\"Squirrel\"}]}";
JSONAssert.assertEquals(expected, actual, false);
The library parses the strings into JSON objects and compares their logical structures.
JSONAssert can also compare org.json
objects.