Forum Discussion
2 Replies
Sort By
- LucianCommunity Hero
Hi,
I created a small piece of code which seems to work:
import groovy.json.* // Define lists to hold all keys def firstJsonList = [] def secondJsonList = [] def thirdJsonList = [] // Create a jsonSlurper object def jsonSlurper = new JsonSlurper() // Parse responses def firstJson = jsonSlurper.parseText( context.expand('${GetFirstJson#Response}') ) def secondJson = jsonSlurper.parseText( context.expand('${GetSecondJson#Response}') ) def thirdJson = jsonSlurper.parseText( context.expand('${GetThirdJson#Response}') ) // Put all the keys in lists firstJson.each { entry -> firstJsonList.add( "$entry.key" ) } secondJson.each { entry -> secondJsonList.add( "$entry.key" ) } thirdJson.each { entry -> thirdJsonList.add( "$entry.key" ) } // Compare the first and second list for (int i = 0; i < firstJsonList.size(); i++) { assert ( firstJsonList[i] == secondJsonList[i] ) } // Compare the first and third list for (int i = 0; i < firstJsonList.size(); i++) { assert ( firstJsonList[i] == thirdJsonList[i] ) }
You can download the whole project from https://github.com/lucadln/soapui/tree/master/SoapUIOS/ModifyXmlInGroovy
Cheers :robotvery-happy:
- nmraoChampion Level 3Would you mind showing the sample data?
Related Content
- 5 years ago
Recent Discussions
- 11 days ago