Ved Ved - 3 months ago 7
JSON Question

How to filter array of arrays?

I have a JSON data. I am pushing this data to another array. The problem i am facing is, i want to filter array whose data

attrs
has
src
property. And push these array to another array. Can anyone will help me in this.I am not getting a way to do this.


My Json data is like:

DATA:

[
{
"data":{
},
"type":"image",
"attrs":{
"x":92,
"y":163,
"width":100,
"height":100,
"src":"http://localhost:63342/wodrobs/app/scripts/views/img/top.jpg",
"cursor":"move",
"opacity":1
},
"transform":"",
"id":0
},
{
"data":{
},
"type":"path",
"attrs":{
"fill":"none",
"stroke":"#000",

"stroke-dasharray":"- ",
"opacity":0.5
},
"transform":"",
"id":17
},


]

Ved Ved
Answer

Got the answer. i was doing silly mistake.

 var filterData= _.filter(jsonData, function (data) {
            return data.attrs.src;
        });