【发布时间】:2021-05-09 07:19:56
【问题描述】:
我像这样过滤一组对象:
[
{
"Username":"00d9a7f4-0f0b-448b-91fc-fa5aef314d06",
"Attributes":[
{
"Name":"custom:organization",
"Value":"zxc"
},
{
"Name":"sub",
"Value":"00d9a7f4-0f0b-448b-91fc-fa5aef314d06"
},
{
"Name":"email_verified",
"Value":"false"
},
{
"Name":"email",
"Value":"zigor@freeallapp.com"
}
],
"UserCreateDate":"2021-02-04T17:59:28.212Z",
"UserLastModifiedDate":"2021-02-04T17:59:28.212Z",
"Enabled":true,
"UserStatus":"UNCONFIRMED"
},
{
"Username":"07c16a30-b994-4267-9794-6fb20739abeb",
"Attributes":[
{
"Name":"custom:organization",
"Value":"asd"
},
{
"Name":"sub",
"Value":"07c16a30-b994-4267-9794-6fb20739abeb"
},
{
"Name":"email_verified",
"Value":"false"
},
{
"Name":"email",
"Value":"2marwan.khatar.39@dankq.com"
}
],
"UserCreateDate":"2021-02-04T17:56:13.787Z",
"UserLastModifiedDate":"2021-02-04T17:56:13.787Z",
"Enabled":true,
"UserStatus":"UNCONFIRMED"
},
以下是精细过滤
let filterarry;
filterarry = jsonObject.filter(Attributes => {
return Attributes.Enabled == true && Attributes.UserStatus == 'UNCONFIRMED';
});
console.log(filterarry);
我正在尝试按具有以下属性的属性进行过滤: 具有 custom:organization 和值 zxc 的属性 我该怎么做??
"Attributes":[
{
"Name":"custom:organization",
"Value":"zxc"
},
我尝试了几种方法,但我在输出中得到了空数组 谢谢
【问题讨论】:
标签: javascript arrays typescript filter