1

I have two jsons array responses with same data but the attributes are different. How to compare this kind of jsons.

json 1: comments: [ { "onetag1": "1", "onetag2": "2" }, { "onetag11": "3", "onetage12": "4" } ]

json 2:

newcommentslist: [ { "newtag2": "2", "newtag1": "1" }, { "newtag11": "3", "newtage12": "4" } ]

Kannan
  • 47
  • 3

1 Answers1

0

Use JsonPath:

* def first = [ { "onetag1": "1", "onetag2": "2" }, { "onetag11": "3", "onetage12": "4" } ]
* def values = $first[*].*
* match values == ['1', '2', '3', '4']

Or transform one of them: https://stackoverflow.com/a/53120851/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248