Forum Discussion
nila2020
New Contributor
I am new to groovy script, Please can you explain what is [b:2,a:1], Thank you in advance
JHunt
6 years agoCommunity Hero
That's a Map. It's just like an object in JSON. So for parsing a response, and checking the keys of the object, you would do something like this:
String response = '''{ "DataValue": [ { "ABC1": "Value", "ABC2": "Value" }, { "ABC1": "Value", "ABC2": "Value" } ] }''' new groovy.json.JsonSlurper().parseText(response)["DataValue"].each { dataValue -> ArrayList<String> keys = dataValue.collect { key, value -> key } assert keys == [ "ABC1", "ABC2" ] }
And the assertion will fail if the order is different to what you are expecting.
- nila20206 years agoNew Contributor
Thank you for your response, Appreciate your help
Related Content
- 3 years ago
Recent Discussions
- 15 years ago