var data = {
"2738": {
"Question": "How are you?",
"Answer": "I'm fine"
},
"4293": {
"Question": "What's your name?",
"Answer": "My name is John"
}
}
var newQuestion = "Where do you live?";
var newAnswer = "I live in France";
To add a new question and answer separately to the data with a specific id, you can use different methods like:
data[6763] = {
"Question" : newQuestion,
"Answer" : newAnswer,
}
If you wish to add the question and answer one by one (for executing code in between), here are some attempts that will not work:
data[6763].Question = newQuestion;
data[6763].Answer = newAnswer;
data[6763] = {"Question" : newQuestion};
data[6763] = {"Answer" : newAnswer};
Object.getOwnPropertyNames(data)[6763].Question = newQuestion;
Object.getOwnPropertyNames(data)[6763].Answer = newAnswer;