Created
November 18, 2013 09:53
-
-
Save aseigneurin/7525386 to your computer and use it in GitHub Desktop.
Parse a JSON file and output a SQL script with Node.js.
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'); | |
var data = fs.readFileSync(process.argv[2], { | |
encoding: 'ascii' | |
}); | |
var json = JSON.parse(data); | |
for (var list in json) { | |
var devices = json[list]; | |
for (var i = 0; i < devices.length; i++) { | |
var device = devices[i]; | |
if (device["uid"]) | |
console.log("UPDATE panel.device SET hardware_id = '" + device["devid"] + "' WHERE uid = '" + device["uid"] + "' AND project = 4;"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment