javascript - How to get number of response of JSON? -
this question has answer here:
that json request
http://www.omdbapi.com/?s=harry
follow link see structure of response. how can number of objects in order create for loop?
first need json.parse data (string) in case:
var data = json.parse(string); getting number of items is:
data.length; you can same file (assuming node.js):
require('fs').readfile(json.parse(file), 'utf8', function (err, data { if (err) throw err; // data parsed }); then iterate using for-loop array you're interested in:
for (var prop in data) { // item var item = data[prop]; } iteration nowadays doesn't require a-priori knowledge of array length:
for (var = 0; < data.length; ++i) that json seems have search array of objects (see self: http://json.parser.online.fr/)
Comments
Post a Comment