1

I need to assert two JSON Objects, for that I am using JSONAssert jar.

import org.skyscreamer.jsonassert.JSONAssert;
.
.//some code
.
JSONAssert.assertEquals(obj1, jObject, true);

When the control reaches JSONAssert line, the execution just stops. I am passing 'obj1' a json object from converting a json string and is in form {"a":1} and the second argument is picked from a txt file and is in format {"a":2}.

Assertion error is expected but nothing happens, no error ... nothing.

When trying the jsonAssert jar in a independent java program where json objects are initialised there itself, it works fine.

Any suggestions will be helpful, Thanks!!

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
user3712016
  • 203
  • 3
  • 6
  • 16

1 Answers1

-1

JSONAssert.assertEquals would throw an AssertionError in the actual JSON doesn't "match" the expected one.

Or, if one of the JSONs can't be parsed, it would throw a JSONException.

One possible problem is that you have some catch (Throwable e) clause which "silences" the assertion error and/or parse exception.

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103