I've come across a Json file that contains a key that has a hypen in it. I've done tons of searching on Google but can't figure out how to read this.
Example Json:
"country_name":"United States",
"iso-3166":"US",
etc...
I can read the 'counry_name' just fine. But the 'iso-3166' is throwing an error because it thinks it's a minus sign.
Here's an example of the code I'm using... I've tried many ways of getting the iso value with no luck. This is just the latest attempt.
httpGet(params) { resp ->
def json = resp.data
for (rec in json.response.countries) {
cName += "$rec.country_name ($rec.['iso-3166'])"
}
}
Desired output is 'United States (US)'
Appreciate any help!