Created
April 9, 2019 15:29
-
-
Save juanbrusco/5048c79e04050fe68e877085e739995f to your computer and use it in GitHub Desktop.
Read json file - Javascript
This file contains hidden or 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
questions_template = []; | |
getQuestionsTemplate() { | |
let template = require('./datamodel_questions_template.json'); | |
for (var key in template) { | |
if (!template.hasOwnProperty(key)) continue; | |
if (key === "questions") { | |
var obj = template[key]; | |
for (var prop in obj) { | |
if (!obj.hasOwnProperty(prop)) continue; | |
obj[prop].number = prop; | |
this.questions_template.push(obj[prop]); | |
} | |
} | |
} | |
console.log(this.questions_template); | |
} | |
// File: "datamodel_questions_template.json" | |
{ | |
"_id": "datamodel_questions_template", | |
"questions": { | |
"004": { | |
"description": "Is billing calendar based?", | |
"example": "(quarterly Jan 1st - March 31st), (monthly Feb 1st - Feb 28th), (weekly Sunday - Saturday).", | |
"parent_question_id": "003", | |
"questiontype": "radiobutton", | |
"answer_options": [ | |
"Yes", | |
"No" | |
], | |
"next_question": "005", | |
"actions": { | |
"Yes": { | |
"selecttables": [], | |
"selecttags": [] | |
} | |
} | |
}, | |
"005": { | |
"description": "Is there special holiday billing, rates or handling for this contract?", | |
"parent_question_id": "004", | |
"questiontype": "radiobutton", | |
"answer_options": [ | |
"Yes", | |
"No" | |
], | |
"next_question": "006", | |
"actions": { | |
"Yes": { | |
"selecttables": [ | |
"holiday_dim" | |
], | |
"selecttags": [ | |
"holiday_dim.holiday_id.display_ui", | |
"holiday_dim.holiday_id.selected" | |
] | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment