Ask a Question

Comparing two different JSON response [ArrayList] Elements

nurgustianto
New Contributor

Comparing two different JSON response [ArrayList] Elements

Dear All,

 

Kindly need Your help & advice, I would like to compare / Match Content Assertion, but the problem is as the JSON files has multiples elements array, as described below screenshot : 

Q1.png

right after the offer, there's a lot of OfferID -> this is considered [shop steps]as my source or files that I would like to compare, 

and below screenshot is the target : 

Q2.png

On the above screenshots is the OfferID that I would like to compare, is the OfferID actually the same ID as the previous ID [from shop step]. I doubt that I can use Match Content Assertion since the elements that I will check are too many. How to handle this scenario?

Any help is really appreciated. 

FYI : @apmorales 

Cheers,

 

Anto.

2 REPLIES 2
nmrao
Community Hero

I am not sure how you compare currently.

 

It should be fairly easy to compare using script assertion.

 

Here is the sample code to compare two lists

https://stackoverflow.com/questions/2544258/how-can-i-compare-two-lists-in-groovy

 

Of course, there may be different approaches to achieve the same.



Regards,
Rao.
nurgustianto
New Contributor

Hi @nmrao ,

 

Really appreciate Your help, 

I have already taken a look on the web that You shared, unfortunately, I'm not sure how to do that in ReadyAPI, since I'm new to ReadyAPI and GroovyScript. 

 

cancel
Showing results for 
Search instead for 
Did you mean: