
We might face a scenario where our response has json object having value — array of objects like below.
“filters”: [
{
“id”: 101,
“name”: “VENDOR”,
“isAllowed”: false
},
{
“id”: 102,
“name”: “COUNTRY”,
“isAllowed”: true
},
{
“id”: 103,
“name”: “MANUFACTURER”,
“isAllowed”: false
}
]
We can get the value in multiple ways, but effective and easiest one is by using array filter > this filters for our condition but again return an array. We can then use spread operator to flatten it and get the property value like below.
Note that we can write a function which returns the value for the given property of an object. This ensures our code is clean and easy to maintain.


Leave a comment