How to access map values ​​in groovy using a key containing a dot?

I have a map like this:

data = {user.name: "John",
        user.surname: "Doe",
        city: "NY"}

I can access the "city" this way:

data.city

Is there a similar way to access the user.name attribute?

+5
source share
1 answer

Assuming you meant:

data = [ 'user.name':"John", 'user.surname':"Doe", city:"NY" ]

(square brackets for the map definition and quotation marks around the names with dotted keys), I believe that

data.'user.name'

gotta do it

+9
source

All Articles