How do I get the length of a JSON file?

First, you’ll have to create a properly formatted JSON file. Once you’re done with that, getting the current number of objects from that list is a piece of cake.

var json = data;

Pull in the feed via getJSON function, toss it into a variable (I called mine json) and grab the length with .length. My example alerts the number of entries but you can do what ever you’d like.

Back to Blog