有没有任何新的 JSONAssert 替代品具有比较模式?

huangapple go评论81阅读模式
英文:

Are there any new JSONAssert alternatives having compare modes?

问题

我想知道是否有其他类似的库可以替代JSONAssert库,以类似的方式对JSON文件进行断言。这个替代方案应该有类似于JSONCompareMode的功能,比如STRICT和NON_EXTENSIBLE等。JSONAssert库最后的提交似乎很久以前了-> https://github.com/skyscreamer/JSONassert/commits/master,看起来这个项目不再继续开发。

英文:

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.

答案1

得分: 2

这里有一个历史悠久且具有相当全面功能的活跃的 JsonUnit:https://github.com/lukas-krecan/JsonUnit

英文:

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

答案2

得分: 1

ModelAssert具有比较字符串文字、文件和JsonNode对象中的JSON和YAML的能力。它基于Jackson库:

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

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

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

全面披露 - 我是ModelAssert的作者。

英文:

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

huangapple
  • 本文由 发表于 2020年5月5日 19:20:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/61611927.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定