【发布时间】:2019-03-20 16:03:46
【问题描述】:
我正在尝试重新格式化我的 JSON 以使用外部 API
我当前的 JSON 结构:
{
"serviceConfigs": {
"servicecode": "SC1",
"specifiers": {
"Brand ID": {
"text": {
"value": "test",
"type": "text"
}
},
"Program ID": {
"text": {
"value": "test",
"type": "text"
}
}
}
}
}
期望的输出:
{
"serviceConfigs": [{
"servicecode": "SC1",
"specifiers": {
"Brand ID": {
"text": {
"value": "test",
"type": "text"
}
},
"Program ID": {
"text": {
"value": "test",
"type": "text"
}
}
}
}]
}
所以目前 serviceConfigs 是在一个对象中,但我想把它放到一个数组中
我目前的想法是使用推送命令,但我不确定如何访问对象(循环?)。
【问题讨论】:
-
data.serviceConfigs = [data.serviceConfigs]?
标签: javascript json reformatting