Forum Discussion
JHunt
Community 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.
nila2020
6 years agoNew Contributor
Thank you for your response, Appreciate your help
Related Content
- 3 years ago
Recent Discussions
- 10 days ago