After hourlong searching I have found no solution about my problem and now I hope someome could be able to help me here.
So basically what I am looking for is a way to generate a JavaScript file (*.js) from a JSON (Schema) file automatically using NodeJS. I know that there are things like fs.write, but this is surely no fitting way for my problem, I think. And so far I have found no other way to create my JavaScript file other than that.
Basically I want to translate:
{
"type":"object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"default":12
},
"favorite_color": {
"type": "string"
},
"gender": {
"type": "string",
"enum": [
"male",
"female"
]
}
}
}
Into JavaScript code like:
var data = function() {
data.baseConstructor.call(this);
this.name = ko.observable("");
this.age = ko.obseravble(12);
this.favorite_color = ko.observable();
this.gender = ko.observable(data.genderModes.male);
}
data.genderModes = {
male: "male",
female: "female"
}
Would someone be able to give me a hint to my problem?