I have a server side REST api, which can return a jsonyfied data with arbitrary structure. On a client side I have an Angular application.
Resource is defined:
module.factory('SearchQueries', function ($resource){
return $resource('/instances/searches/:_id', {_id: '@_id'});
})
After I try to get data from my api:
$scope.search_queries = SearchQueries.query(null, function(args){
console.log('success: ', args);
for (i in args) {
}
});
The client side receives a data with kinda structure:
{"2": "serfgserg", "3": "sdfgdfg", "4": "sdgdfhdfghfgh", "5": "sdgdfhdfghfgh"}
But! In the success function of the Angular resource every symbol of the data is the value of one element object.
[{"0":"s","1":"e","2":"r","3":"f","4":"g", e.t.c
Why is it done? How to prevent or use it rightly?
edit:
If I return an array from the server:
res = json.dumps(["sdf", "asdf", "asdf"])
return Response(response=res, mimetype='application/json',
status=status)
Never mind I have the same result:
[{"0":"s"},{"0":"d"},{"0":"f"},{"0":"a"},{"0":"s"},{"0":"d"},{"0":"f"} // e.t.c