Questions tagged [jsonunit]

7 questions
7
votes
3 answers

how to tell assertJsonEquals to ignore one field in comparing

I am using assertJsonEquals of JsonUnit I do the following in my code: assertJsonEquals(resource("ExpecedResponse.json"), ActualResponse, when(IGNORING_ARRAY_ORDER)); The ActualResponse has the response from a HTTP POST.…
Saffik
  • 911
  • 4
  • 19
  • 45
3
votes
1 answer

How to get assertion result from JsonUnit?

I'm working on a test-framework where I'd like to use JsonUnit for comparing two JSONs. My assertion looks like this: JsonAssert jsonAssert = assertThatJson("{\"a\":1, \"b\":2}") .when(Option.IGNORING_ARRAY_ORDER) .isEqualTo("{b:2,…
Ninius86
  • 295
  • 6
  • 14
1
vote
0 answers

How to ignore node with sub nodes in JsonAssertions?

I am using net.javacrumbs.jsonunit.assertj, JsonAssertions, assertThatJson to compare two jsons. I need to ignore node with array and sub-nodes. So in this example I would like to ignore all in node "ignoreAllIn" { "md": { "i":…
Simon
  • 11
  • 2
1
vote
1 answer

How to create a matcher in JsonUnit with more than one parameter

I want to create a custom matcher with more than parameter (for example isBetween) and use it for comparison in JsonUnit. How do I do that?
Lukas
  • 13,606
  • 9
  • 31
  • 40
1
vote
0 answers

Query in passing parameter to JsonAssert.whenIgnoringPaths()

My aim is to skip Time related column from json comparison. I have referred this https://github.com/lukas-krecan/JsonUnit & it helped me a lot but my problem is I have more than one column to be skipped. And the columns which needed to be skipped…
shrusthip
  • 85
  • 1
  • 10
0
votes
1 answer

Jsonassert ignore key

There are 2 Json strings to compare. 1 "values": { "-1487778947": { "field1": "xxx", "field2": "yyy", "field3": { "zzz": { "field4": 21, "field5": 28 } } }, "-1820451085": { …
0
votes
1 answer

Java JSON unit test pass with wrong value

I have the following function: public class NorthboundApiLogicTest { @Test public void testIfParametersValuesAreCorrect() { String body = "{\"exception\":\"world\",\"error\":\"Not Found\",\"message\":\"hello\"" +…
Nakrule
  • 511
  • 8
  • 24