strangenewstar strangenewstar - 1 year ago 98
Groovy Question

Return Nested Key in Groovy

I am trying to determine the best way to return nested key values using groovy. If I have a map:

def map = [
OrganizationName: 'SampleTest',
Address: [
Street: '123 Sample St',
PostalCode: '00000',

Is there a way to return all of the keys?
? If I didn't have an map within a map I could use map.keySet() as String[]. Should I just loop through each key and see if it is an instanceof another map?

Answer Source

There's no such method You're looking for in groovy. You need to do it using instanceof and probably a recursive method.