我目前有一个结构如下的 JSON 文件
[
{
"firstKey": {
"item": "string",
"item2": "string",
"item3": "string"
}
},
{
"secondKey": {
"item": "string",
"item2": "string",
"item3": "string"
}
},
.
.
.
]
有没有办法改成
"firstKey": {
"item": "string",
"item2": "string",
"item3": "string"
},
"secondKey": {
"item": "string",
"item2": "string",
"item3": "string"
},
.
.
.
这样我就可以直接将其复制到 JSON 并将其导入到 Firebase 实时数据库。
最佳答案
我认为不建议您将其更改为第二种格式。您可以映射第一个中的数组并将值插入到您的 firebase 数据库中。
示例:
const my_array = [
{
"Key": {
"item": "string",
"item2": "string",
"item3": "string"
}
},
{
"Key": {
"item": "string",
"item2": "string",
"item3": "string"
}
}
]
my_array.map((value)=>{
//you can now insert value into your database
})
关于javascript - 重构 JSON 以与 Firebase 实时数据库一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56509643/