Created
February 4, 2016 13:55
-
-
Save a0sy/6f69a957f23f034ad03e to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="UTF-8" ?> | |
<package> | |
<job> | |
<script language = "JavaScript" src = "lib/underscore.js"></script> | |
<script language = "JavaScript" src = "lib/json2.js"></script> | |
<script language = "JavaScript"> | |
var Setting = function() { | |
this.basePath = "C:\\app" | |
// json files | |
this.jsonFiles = [ | |
"setting\\one.json", | |
"setting\\two.json" | |
]; | |
} | |
Setting.prototype.parseFiles = function(jsonFiles) { | |
_.each(jsonFiles, function(file) { | |
var propName = file.match(/^.*\\(.*)\.json$/); // ex: one | |
this[propName[1]] = JSON.parse(includeFile(this.basePath + "\\" + file)); // setting.oneのようにしたいがthisがundefined | |
}); | |
} | |
var setting = new Setting(); | |
setting.parseFiles(setting.jsonFiles); | |
WScript.Echo(setting.one.hoge); //one.jsonの値出力 | |
function includeFile(file) { | |
var fso = new ActiveXObject("Scripting.FileSystemObject"), | |
fileStream = fso.openTextFile(file), | |
fileData = fileStream.readAll(); | |
fileStream.Close(); | |
return fileData; | |
} | |
</script> | |
</job> | |
</package> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment