ekino / jcv Goto Github PK
View Code? Open in Web Editor NEWJSON Content Validator (JCV) allows you to compare JSON contents with embedded validation.
Home Page: https://ekino.github.io/jcv
License: MIT License
JSON Content Validator (JCV) allows you to compare JSON contents with embedded validation.
Home Page: https://ekino.github.io/jcv
License: MIT License
Hello,
I was wondering if it would be nicer to have the usually used jsonMatcher()
method strict by default (.mode(JSONCompareMode.STRICT)
). Moreover we could add another method like unorderedJsonMatcher()
to perform assertions when the order can change.
This would be somehow like what we have in assertj.
What do you think about that ?
A JsonValueComparator
uses the same type for the actual
and expected
parameters. This may be problematic when the actual type is not the same as the expected type.
Here's an example:
Actual is
{
"date": null
}
Expected is
{
"date": "{#date_time_format:iso_instant#}"
}
A ClassCastException
will be thrown because "date"
will be "deserialized" as a null JSONObject
, and DateTimeFormatComparator
expects an actual
of type String
.
Hi,
Could you please provide a changelog listing the changes between two releases ? It would help this library consumers a lot.
Thanks :)
Hi,
it could be cool to provide a wiremock module to validate request or response body json with JCV validators.
In wiremock, when we try to compare a json array with another one but not in the same order, the EqualToJsonPattern
doesn't match. ( here is an issue in wiremock repository : wiremock/wiremock#1230 ). If we use a JCV with wiremock it should fix this.
If you want to test the current EqualToJsonPattern
error, here is a test :
@Test
void reproduceFailingIgnoreArrayOrder() {
var expected = "{ \"array\": [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\"] }";
var actual = "{ \"array\": [\"b\",\"a\",\"d\",\"c\",\"e\",\"f\",\"g\",\"h\"] }";
var pattern = new EqualToJsonPattern(expected, true, false);
var result = pattern.match(actual);
var exact = result.isExactMatch();
assertTrue(exact);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.