如何使用变量值命名我的站点对象的键?因为当我写“site”时,输出等于单词“site”而不是变量值。
dataArray = {
sites: {
site: {
username: username,
followers: followers,
details: details,
diff: 0
}
},
graph: {
data: [0, 0, 0, 0, 0, 0]
},
sort: {
order: [0, 1, 2, 3, 4, 5]
}
};
为了检索这样的东西:
{
"sites":{
"dribbble":{
"username":"JeremDsgn",
"followers":17,
"details":{
"following":14,
"likes":8,
"comments":4,
"views":252
},
"diff":0
},
"twitter":{
"username":"JeremDsgn",
"followers":17,
"details":{
"following":14,
"likes":8,
"comments":4,
"views":252
},
"diff":0
}
},
"graph":{
"data": [0, 0, 0, 0, 0, 0]
},
"sort":{
"order": [0, 1, 2, 3, 4, 5]
}
}