我无法将结果对象附加到现有对象,任何人都可以在这里帮助我
这是我的数据
var data = [];
data.push("result");
while(inc.next()){
data.push({
"short_description": inc.getValue('short_description'),
"description": inc.getValue('description')
})
}
结果如下 JSON 格式
["result",{"short_description":"Unable to access team file share","description":"I can access my personal folder but can't access my team's folder on our file share."},{"short_description":"Employee payroll application server is down.","description":"Employee payroll application server is down.Not able to login with valid credentials."}]
但我期待如下
{"result": [{"short_description":"Unable to access team file share","description":"I can access my personal folder but can't access my team's folder on our file share."},{"short_description":"Employee payroll application server is down.","description":"Employee payroll application server is down.Not able to login with valid credentials."}]}
也许是这样的:
var data = {"result": []}; // Initialize data as an object with a "result" key
while (inc.next()) {
// Push each object to the "result" array
data["result"].push({
"short_description": inc.getValue('short_description'),
"description": inc.getValue('description')
});
}