I am working to filter a large json data set, I'd like to know how can I select json objects vertically.
Lat's take this small example, I'd like to select all the books with the name of author contains 'Evelyn'
data= [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price":8
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 8
},
{ "category": "fiction",
"author": "Evelyn Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
as a result I should get:
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 8
},
{ "category": "fiction",
"author": "Evelyn Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
Can I do it this way:
$.each(data,function(i,el)
{
var newdata;
if (data.author.contains('Evelyn')) newdata.push()
});
Another way :
data.where( "( n, i ) => n.author.contains('Evelyn') " ) ;
Do you have where is the problem in the both ways, what is the fastest ways to tackle this problem as I have a huge dataset ?