如何使用给定数组动态获取属性
how can i get attributes dynamicly with given array
我需要用给定的数组搜索属性我试过这段代码:
["client_id","client_secret"] map (ident , indexOfIdent ) -> {
HeaderName: ident,
HeaderValue: attributes.headers.ident
}
回复是:
[
{
headerName: "client_id",
headerValue:null
},
{
headerName: "client_secret",
headerValue:null
}
]
我知道我的代码正在寻找名称为“ident”的属性。但我不知道如何进行动态搜索。感谢您的帮助。
您可以使用允许在内部使用表达式的[
括号
["client_id","client_secret"] map (ident , indexOfIdent ) -> {
HeaderName: ident,
HeaderValue: attributes.headers[ident]
}
我需要用给定的数组搜索属性我试过这段代码:
["client_id","client_secret"] map (ident , indexOfIdent ) -> {
HeaderName: ident,
HeaderValue: attributes.headers.ident
}
回复是:
[
{
headerName: "client_id",
headerValue:null
},
{
headerName: "client_secret",
headerValue:null
}
]
我知道我的代码正在寻找名称为“ident”的属性。但我不知道如何进行动态搜索。感谢您的帮助。
您可以使用允许在内部使用表达式的[
括号
["client_id","client_secret"] map (ident , indexOfIdent ) -> {
HeaderName: ident,
HeaderValue: attributes.headers[ident]
}