Q:

How to get particular property in ajax response?

This is the ajax response I am getting from the backend. I need to search for property "select": true from this response. 
Ajax response getting from the backend:
[
[
    {
        "itemCategory": "Bedroom",
        "task": "Bedroom",
        "children": [
            {
                "task": "Smart TV",
                "price": 300,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            },
            {
                "task": "Bed",
                "price": 500,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Micro oven",
                "price": 200,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            },
            {
                "task": "Refrigerator",
                "price": 250,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Dining Table",
                "price": 100,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    }
],
[
    {
        "itemCategory": "Bedroom",
        "task": "Bedroom",
        "children": [
            {
                "task": "Smart TV",
                "price": 300,
                "leaf": true,
                "labor": "5",
                "rate": 4,
                "text": "",
                "select": true
            },
            {
                "task": "Bed",
                "price": 500,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Micro oven",
                "price": 200,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            },
            {
                "task": "Refrigerator",
                "price": 250,
                "leaf": true,
                "labor": "4",
                "rate": 3,
                "select": true
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Dining Table",
                "price": 100,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    }
],
[
    {
        "itemCategory": "Bedroom",
        "task": "Bedroom",
        "children": [
            {
                "task": "Smart TV",
                "price": 300,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            },
            {
                "task": "Bed",
                "price": 500,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Micro oven",
                "price": 200,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            },
            {
                "task": "Refrigerator",
                "price": 250,
                "leaf": true,
                "labor": "",
                "rate": 0,
                "text": ""
            }
        ]
    },
    {
        "itemCategory": "Kitchen",
        "task": "Kitchen",
        "children": [
            {
                "task": "Dining Table",
                "price": 100,
                "leaf": true,
                "labor": "5",
                "rate": 4,
                "text": "",
                "select": true
            }
        ]
    }
 ]
]

This is the expected output:
{
"task": "Smart TV",
"price": 300,
"leaf": true,
"labor": "5",
"rate": 4,
"text": "",
"select": true
},
{
"task": "Refrigerator",
"price": 250,
"leaf": true,
"labor": "4",
"rate": 3,
"select": true
},
{
"task": "Dining Table",
"price": 100,
"leaf": true,
"labor": "5",
"rate": 4,
"text": "",
"select": true
}

Here first I am comparing the project name. Once I got that, I need to search for "select: true"
var project = "demo";
       Ext.Ajax.request({
          url: '/common/services/general/basicOperations/getDataByModelUsingGetMethod',
          method: 'GET',
          params: {
              actionId: 'estimatordata',
              dataJson: '{"aspectType":"Painting Estimator"}'
          },
          success: function(response) {
              try {
                  var response = response.responseText;
                  var resObj = Ext.decode(response);
                  for (var i = 0; i < resObj.data.length; i++) {
                      if (resObj.data[i].refDataNameName == project) {
                        console.log(JSON.stringify(resObj.data[i]['allGridsData'], null, 4));
                      }
                  }
                  this.lookupReference('selectionsinquiryDetailGrid').getStore().loadData(
                      arr
                  );
              } catch (e) {
                  console.log(e);
              }
          },
          failure: function(response) {

          },
          scope: this
      });

Thanks in advance.

A:

This is approach without external libraries. To simplify operations on nested arrays flatMap was defined.
flatMap -> [[1,2], [3,4]] to [1,2,3,4]

const data = [ [ { itemCategory: 'Bedroom', task: 'Bedroom', children: [ { task: 'Smart TV', price: 300, leaf: true, labor: '', rate: 0, text: '' }, { task: 'Bed', price: 500, leaf: true, labor: '', rate: 0, text: '' } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Micro oven', price: 200, leaf: true, labor: '', rate: 0, text: '' }, { task: 'Refrigerator', price: 250, leaf: true, labor: '', rate: 0, text: '' } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Dining Table', price: 100, leaf: true, labor: '', rate: 0, text: '' } ] } ], [ { itemCategory: 'Bedroom', task: 'Bedroom', children: [ { task: 'Smart TV', price: 300, leaf: true, labor: '5', rate: 4, text: '', select: true }, { task: 'Bed', price: 500, leaf: true, labor: '', rate: 0, text: '' } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Micro oven', price: 200, leaf: true, labor: '', rate: 0, text: '' }, { task: 'Refrigerator', price: 250, leaf: true, labor: '4', rate: 3, select: true } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Dining Table', price: 100, leaf: true, labor: '', rate: 0, text: '' } ] } ], [ { itemCategory: 'Bedroom', task: 'Bedroom', children: [ { task: 'Smart TV', price: 300, leaf: true, labor: '', rate: 0, text: '' }, { task: 'Bed', price: 500, leaf: true, labor: '', rate: 0, text: '' } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Micro oven', price: 200, leaf: true, labor: '', rate: 0, text: '' }, { task: 'Refrigerator', price: 250, leaf: true, labor: '', rate: 0, text: '' } ] }, { itemCategory: 'Kitchen', task: 'Kitchen', children: [ { task: 'Dining Table', price: 100, leaf: true, labor: '5', rate: 4, text: '', select: true } ] } ] ]

function flatMap(arr) {
  return arr.reduce((acc, cur) => {
    acc = acc.concat(cur)
    return acc
  }, [])
}

const result = flatMap(flatMap(data).map(x => flatMap(x.children))).filter(x => x.select == true)
console.log(result)

