Вы можете использовать map
и filter
следующим образом:
var DATA={'device_groups':[{'id':'1','name':'group 1','devices':[{'id':11,'name':'device 11','active':1},{'id':12,'name':'device 12','active':0},{'id':13,'name':'device 13','active':0}]},{'id':'2','name':'group 2','devices':[{'id':21,'name':'device 21','active':1},{'id':22,'name':'device 22','active':0},{'id':23,'name':'device 23','active':1}]},{'id':'3','name':'group 3','devices':[{'id':31,'name':'device 31','active':1},{'id':32,'name':'device 32','active':0},{'id':33,'name':'device 33','active':1}]}]}
const filtered = DATA.device_groups.map(a => a.devices.filter(a => a.active === 1)),
output = [].concat(...filtered);
console.log(output)
Или с использованием простого reduce
var DATA={'device_groups':[{'id':'1','name':'group 1','devices':[{'id':11,'name':'device 11','active':1},{'id':12,'name':'device 12','active':0},{'id':13,'name':'device 13','active':0}]},{'id':'2','name':'group 2','devices':[{'id':21,'name':'device 21','active':1},{'id':22,'name':'device 22','active':0},{'id':23,'name':'device 23','active':1}]},{'id':'3','name':'group 3','devices':[{'id':31,'name':'device 31','active':1},{'id':32,'name':'device 32','active':0},{'id':33,'name':'device 33','active':1}]}]}
const devices = DATA.device_groups
.reduce((a,d) => a.concat(d.devices.filter(f => f.active)),[]);
console.log(devices)