CraZyDroiD
CraZyDroiD

Reputation: 7105

Count the number of objects in json array

I'm using a GET method to view a json file as follows.

$scope.train = function () {

            var url = 'http://localhost/heart/api/restApiController/dataset.json';

            $http({
                method: 'GET',
                url: url


            }).then(function (data) {

            });


        };

Now I want to count numberof objects in the json file.how can I do it?

log of data

Object {data: Array[5], status: 201, config: Object, statusText: "Created"}
config:Object
data:Array[5]
headers:(d)
status:201
statusText:"Created"

So there are 5 objects in this array.how can I get this value 5 from AngularJS code?

Upvotes: 1

Views: 5789

Answers (1)

Andreas Scheibleger
Andreas Scheibleger

Reputation: 297

You can simply use the standard length

data.data.length

Upvotes: 4

Related Questions