How to I parse JSON list of dictionaries in javascript -
i'm new javascript , need iterate through json list of dictionaries create list each key.
here's json:
[ { "date": "aug. 14, 2015", "reel": "reel 1", "job": "color correction", "status": "in progress", "completion": "60" }, { "date": "aug. 14, 2015", "reel": "reel 1", "job": "conform", "status": "in progress", "completion": "70" }, { "date": "aug. 14, 2015", "reel": "reel 2", "job": "scanning", "status": "complete", "completion": "100" }, { "date": "aug. 12, 2015", "reel": "reel 1", "job": "qc only", "status": "in progress", "completion": "50" } ]
i'm using function read in json:
$.getjson('cgi-bin/fakedata.txt', function(main)
i want able access main['date'] = ['august 12, 2015','august 14, 2015']
etc...
below runnable node program. looked me trying dates separate array. access them dates[0].
#!/usr/bin/node json = [ { "date": "aug. 14, 2015", "reel": "reel 1", "job": "color correction", "status": "in progress", "completion": "60" }, { "date": "aug. 14, 2015", "reel": "reel 1", "job": "conform", "status": "in progress", "completion": "70" }, { "date": "aug. 14, 2015", "reel": "reel 2", "job": "scanning", "status": "complete", "completion": "100" }, { "date": "aug. 12, 2015", "reel": "reel 1", "job": "qc only", "status": "in progress", "completion": "50" } ]; function getdates(main) { dates = []; (var = 0; < main.length; i++ ) { dates.push(main[i].date); } return dates; }; dates = getdates(json); console.log(dates);
Comments
Post a Comment