开发者

How to access map values in groovy by key containing dot?

I have map like this:

data = 开发者_高级运维{user.name: "John",
        user.surname: "Doe",
        city: "NY"}

I can access attiribute 'city' this way:

data.city

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


Assuming you meant:

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

(square braces for the map definition, and quotes round the dotted key names), I believe that

data.'user.name'

should do it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜