How to handle Json array efficiently?

i have an json array like this

//data.json
{
"one":   [ {"name":"john"},{"name":"joe"},{"name":"vicky"} ],
"two":   [ {"name":"mark"},{"name":"nike"},{"name":"albert"} ]
}

//filter.js
angular.module('eventFilters', ['calenderServices']).filter('compare', function(Name) {
var e=Name.query();

return function(input) {
alert(e['one'].length) //-->displays nothing
}

i am trying to retrieve the length of the array "one" and "two", but jsondata['one'].length is not returning the length, it is not displaying any thing. My angular restful services which i have used to get the json data from external file is correct, no doubt in that. since i am getting json data in filter, i couldn't use $scope.e=Name.query(); so i tried using 'var', it was working fine with my old json data, but not with my new json file. what may be the problem?

Thanks in advance

Not entirely sure what is the exact problem you are trying to solve here but the issue into which you are bumping here is that you've got an async call (.query()) that won't return results immediately (I suspect that you are using $resource and its syntax might suggest that is synchronous, more info here: http://stackoverflow.com/a/11966512/1418796).

Now, filters are not prepared to work with asynchronous results really so what you are trying to do here won't work. Ultimately the issue is more linked to the asynchronous function calls that to filters.

Would love to help more here but I'm not clear what you are trying to achieve, functionally speaking.