How to save this data into JSON file?
var objJson = {
questionType : "singleLine",
maxCharecters : 25,
question : "What is the capital of India?",
answer : "Delhi"
}
How to save this data into JSON file?
var objJson = {
questionType : "singleLine",
maxCharecters : 25,
question : "What is the capital of India?",
answer : "Delhi"
}
You can use JSON.stringify(objJson)
to turn it into a string, then save it to a file. I can't tell what you mean by Visual Studio Code, but if you are using NodeJS (like a VS Code extension) you can use the File System Module to save it.
Example:
const fs = require('fs');
fs.writeFileSync(
'data.json',
JSON.stringify(objJson)
);