I am willing to compare and match each object sequentially in two JSONs and report mismatches in the report, can we do this natively in karate?

Viewed 10

Basically want to achieve something like the below, was thinking if I can do this natively

const obj1Keys = Object.keys(jsonData1);
const obj1Values = Object.values(jsonData1);
const obj2Keys = Object.keys(jsonData2);
const obj2Values = Object.values(jsonData2);

for (let i = 0; i < obj1Keys.length; i++) {
  for (let j = 0; j < obj2Keys.length; j++) {
    if (obj1Keys[i] === obj2Keys[j]) {
      if (obj1Values[2] !== obj2Values[2]) {
        alert("data mismatched");
      }
    }
  }
}

}

Below returns a failure if one of the objects is not matching but it doesn't indicate which one it is

* match jsonData1 == jsonData2
0 Answers
Related