我有一个从Entity Framework 5返回的以下javascript对象,这些对象是从SQL Server数据库获取的。
var a =
{
"questionId":14,
"questionStatusId":1,
"answers":null
}
var b =
{
"questionId":15,
"questionStatusId":1,
"answers":[
{"answerId":34,"correct":true,"response":false,"text":"5","image":null,"questionId":15},
{"answerId":35,"correct":false,"response":false,"text":"50","image":null,"questionId":15}]
}
我想添加一个空的答案对象,然后使用PUT发送回服务器。
如何将答案对象添加到变量a和变量b中?
就像是
var newAnswer = {"answerId":0,"correct":false,"response":false,"text":"","image":null,"questionId":0};
b.answers.push(newAnswer);
可能正是您要寻找的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句