Assert two JSON objects

hey i want to assert two JSON objects , can anyone help me in this.

var jsonData = JSON.stringify(responseBody)

var expectedObject = {
“name” : “john”,
“id” : “doe”

Like this i have two JSON objects , one which i have taken from response and another is expected one which i am preparing in my tests script and i want to match these two objects two check whether they are same or not.

Hello @himanshudwivedi1989, welcome to the community! :wave:

You can use to.eql and write the following:

pm.test('Check if objects are equal', function () {

Hi Siv
thanks for the quick help.

1 Like

This is somehow not working for me.
In case:-
var expectedObject = {
i.e. the order of the fields inside the json structure changes then the assertion fails.
If its actually a JSON object comparision then it should not fail.
Anyway, this can be achieved?