Firebase 按以下方式组织导入的 JSON 文件:
但是导入的文件(以及从 Firebase 导出的文件)是这样组织的:
{
"features" : [ {
"geometry" : {
"coordinates" : [ -77.347191, 36.269321 ],
"type" : "Point"
},
"properties" : {
"name" : "Branch Chapel",
"osm_id" : "262661",
"religion" : "christian"
},
"type" : "Feature"
},
...
Firebase 似乎为“功能”数组中的每个对象分配了一个内部编号。这很好,但是在不知道 Firebase 如何命名的情况下很难引用每个对象 - 而且我有 40 万多个对象。
有没有办法为每个对象分配一个 ID 以防止 Firebase 生成自己的 ID?或者有没有办法在导入数据后以编程方式重命名/重新组织数据?最佳结果是对象由其 osm_id 命名,而不是 Firebase 分配的任意数字。
感谢任何帮助。
最佳答案
去掉方括号并用花括号代替
这个
{
"flags": {
"1": {
"information": "blah",
},
"2": {
"information": "It is great!",
},
"3": {
"information": "Amazing!",
}
}
}
不是这个
[
{
"1": {
"information": "blah",
}
},
{
"2": {
"information": "It is great!",
}
},
{
"3": {
"information": "Amazing!",
}
}
]
关于json - 将对象 ID 分配给 Firebase 中导入的 JSON 的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42379731/