'I have been trying to compare all the contentid's of two api's in Jmeter

I have two api's which has the same contents but only the url changes, and I want to compare all the contents from both APIs using jmeter

I have used json extractor and extracted by using path as $.. contentid given match no as -1 and checked the _All option

I have used beanshell assertion to compare the both APIs response, but one api has the all contentid's in random jumbled format so when I run the assertion I am getting error as assertion failed

For example response of one api has {123,345,678,week,add}

And other api has {add,123,678,week,345}

Can you help and possibly show how to compare them and get success



Solution 1:[1]

Take a look at JSONassert library, it allows comparing the JSON responses ignoring the attributes order and focusing only on content.

Also since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so it worth considering migrating to JSR223 Assertion.

More information: Introduction to JSONassert

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T