I cannot access my JSON object properties. Given this constructor
contractorTestQuestion = function (id, question, multianswer, textanswer, order) {
var cntrQuestion;
this.initialize(id, question, multianswer, textanswer, order);
}
$.extend(contractorTestQuestion.prototype, {
initialize: function (_i, _q, _m, _t, _o) {
cntrQuestion = {
"questid" : _i,
"question": _q,
"multianswer": _m,
"textanswer": _t,
"order": _o,
"answers": [],
"change": 'none'
}
},
addAnswer: function (a) {
answers.push(a);
},
getAnswer: function (idx) {
return this.answers[idx];
}
});
I then create it in my code like this:
var cq = new contractorTestQuestion(qid, q, m, t, tqQuesPos);
what I want to do is cq.question and be able to get the value stored in that field.
I cannot figure out what I’m doing wrong
You cannot just set the properties of
contractorTestQuestionby adding it to a private variable.Set the properties on
thislike:Also, this has nothing to do with JSON which is a data format.