我得到的对象是:
{
Id:3233,
Topics:"topic",
TopicId:101,
Alreadyactiontaken:null,
…
}
但我需要如下所示的json格式传递api:
{
"Data":[
{
"Id":477,
Topics:"topic",
TopicId:101,
Alreadyactiontaken:null,
}
]
}
提前致谢
答案 0 :(得分:2)
然后你只需要创建这样一个对象:
let value = {Id: 3233, Topics: "topic", TopicId: 101, Alreadyactiontaken: null, …}
let apiValue = { Data: [value] }
答案 1 :(得分:0)
您可以将json数据推送到数组中并为此分配密钥。喜欢跟随javascript。
var array = [];
var json = {Id: 3233, Topics: "topic", TopicId: 101, Alreadyactiontaken: null};
array.push(json);
var newdata = {};
newdata.data = array;
console.log(newdata);