I need a query in nested a JSON array like following. I want to check if name is John and if hobbies have sport but it didn't work.
The result of following code like that:
[
{"id":1,"name":"John","hobbies":[{"kind":"sport"},{"kind":"music"}]},
{"id":5,"name":"John","hobbies":[{"kind":"swimming"},{"kind":"opera"}]}
]
but it must be {"id":1,"name":"John","hobbies":[{"kind":"sport"}{"kind":"music"}]}
function MyCtrl($scope, $filter) {
$scope.items = [
{id:1, name:'John',hobbies:[{kind:"sport"},{kind:"music"}]},
{id:2, name:'Steve',hobbies:[{kind:"opera"},{kind:"theatre"}]},
{id:3, name:'Joey'},
{id:4, name:'Mary'},
{id:5, name:'John',hobbies:[{kind:"swimming"},{kind:"opera"}]}];
$scope.filteredData = $filter('filter')($scope.items, {name:'John',hobbies:[{kind:''}]});
$scope.json=JSON.stringify($scope.filteredData);
// $scope.json2=JSON.stringify($scope.y);
};