how to tell assertJsonEquals to ignore one field in comparing
You could use the library https://github.com/skyscreamer/JSONassert that has an assert method that allows customization.
Here's an example of a test that is passing (and such ignoring the value of the time
field)
@Test
public void test() throws JSONException {
JSONAssert.assertEquals("{x: 1, time:123}",
"{x: 1, time:234}",
new CustomComparator(
JSONCompareMode.STRICT,
Customization.customization("time", // json path you want to customize
new ValueMatcher() {
@Override public boolean equal(Object o1, Object o2) {
return true; // in your case just ignore the values and return true
}
}))
);
}
Here's the link to the javadoc of the assertEquals method that I am using in the example: http://jsonassert.skyscreamer.org/apidocs/org/skyscreamer/jsonassert/JSONAssert.html#assertEquals-java.lang.String-java.lang.String-org.skyscreamer.jsonassert.comparator.JSONComparator-