I have a JSON response that contains an array of buckets (and sub-buckets) and I want to assert that they're ordered alphabetically based on one of the properties in the bucket. I've tried the following:
String unsorted = new groovy.json.JsonSlurper().parseText(messageExchange.responseContent)
."data"
.with { groovy.json.JsonOutput.toJson( it ) }
String sorted = new groovy.json.JsonSlurper().parseText(messageExchange.responseContent)
."data"
.sort { -it."foundPatientDisplayNaam" }
.with { groovy.json.JsonOutput.toJson( it ) }
assert sorted == unsorted
But that gives me the following response:
No signature of method: java.lang.String.negative() is applicable for argument types: () values: []
Any ideas?