Created
March 13, 2017 06:19
-
-
Save mattConn/24495231c944786e52b530200a41b966 to your computer and use it in GitHub Desktop.
Loop over an array in JSON file with Node. Hypothetical file here is "data.json", with an array named "array" located immediately within the object (not nested).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
util = require('util'), | |
exec = require('child_process').exec, | |
json = JSON.parse(fs.readFileSync('data.json')); | |
function puts(error, stdout, stderr){console.log(stdout, stderr)} | |
for (var i in json.array){ | |
exec('echo '+json.array[i], puts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment