SK07
7 years agoContributor
Groovy - validate Json array
Json: "prodS": {"langTrans": [{ "Id": "11", lang="EN"}, {"Id": "11", lang="FR"},{ "Id": "12", lang="EN"}, {"Id": "12", lang="FR"}], "rates":[{"Id":"11","rate": 100},{Id":"12","rate":200}] }
Here we have 2 arrays. one is ProdS and other is rates.
I have to validate for each Id under rates array, I should find one lang 'EN' & lang'Fr' for that matching Id under langTrans array.
- SK07
Here you go:
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/json/QueryReferencedDataAndCompare.groovy
See demo
https://ideone.com/qSWfL1
Use log.info instead of println.