Are there any new JSONAssert alternatives having compare modes?

1.1k Views Asked by At

I wonder if there are any alternatives to JSONAssert library which allow asserting a JSON file in a similar way. The Alternative which has a similar feature to JSONCompareMode like STRICT and NON_EXTENSIBLE etc. The last commit in JSONAssert seems to be quite old -> https://github.com/skyscreamer/JSONassert/commits/master and it looks that the project is not developed anymore.

2

There are 2 best solutions below

0
On

There is active JsonUnit with long history and with quite comprehensive features: https://github.com/lukas-krecan/JsonUnit

2
On

ModelAssert has the ability to compare JSON and YAML from String literals, files and JsonNode objects. It's based on Jackson:

https://github.com/webcompere/model-assert

assertJson(Paths.get("src", "test", "resources", "simple.json"))
  .isEqualTo(Paths.get("src", "test", "resources", "simple-copy.json"));

From https://github.com/webcompere/model-assert/blob/main/src/test/java/uk/org/webcompere/modelassert/json/ExamplesTest.java#L228

Full disclosure - I'm the author of ModelAssert