将JSON文件导入Firebase时,如何设置初始密钥对?

时间:2015-02-05 21:43:01

标签: json firebase

Ater将JSON文件导入Firebase,它从0(最顶端的零)而不是locations开始索引。

What ends up in Firebase

这是我导入的JSON文件

[{"locations":
    [{"location_id":1,"location":"2331 Fair","location_type_id":1},
    {"location_id":2,"location":"6800 Norm","location_type_id":1}]
}]

如何摆脱热门0,以便我的引用以[name-of-firebase-database]/locations而不是[name-of-firebase-database]/0/locations开头?

1 个答案:

答案 0 :(得分:4)

从:

更改您的JSON结构
[{"locations":
    [{"location_id":1,"location":"2331 Fair","location_type_id":1},
    {"location_id":2,"location":"6800 Norm","location_type_id":1}]
}]

{"locations":
    [{"location_id":1,"location":"2331 Fair","location_type_id":1},
    {"location_id":2,"location":"6800 Norm","location_type_id":1}]
}

0就在那里,因为您的顶级结构是一个列表。