使用Python解析Firebase JSON [英] Parsing Firebase JSON with Python
本文介绍了使用Python解析Firebase JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下JSON结构
I'm working with the following JSON structures
{
"-L6Tr0Wl5fuG3tDgUPCa": {
"List": "{'x': [0.02245, 0.02196], 'y': [0.96941, 0.97014], 'z': [0.05344, 0.05368]}",
"Index": "17361"
},
"-L6Tr4j05NV6BJKcaRSe": {
"List": "{'x': [0.03196, 0.01537], 'y': [0.96795, 0.96966], 'z': [0.05051, 0.04929]}",
"Index": "17362"
}
}
每个条目的名称都是随机的(例如L6Tr0Wl5fuG3tDgUPCa),只要我们推送新条目,该名称就会由firebase生成.解析和迭代python中这样的JSON文件的每个条目的最佳方法是什么?
The name of each entry is random (e.g. L6Tr0Wl5fuG3tDgUPCa) that is generated by firebase whenever we push a new entry. What is the best way to parse and iterate through each entry of such a JSON file in python?
文件很大,有成千上万个这样的条目.
The file is huge with a couple of thousands of such entries.
推荐答案
我以前从未做过Python,但这似乎在 https://www.python.org/shell/:
I've never done Python before, but this seems to work in https://www.python.org/shell/:
import json
data = {
"-L6Tr0Wl5fuG3tDgUPCa": {
"List": "{'x': [0.02245, 0.02196], 'y': [0.96941, 0.97014], 'z': [0.05344, 0.05368]}",
"Index": "17361"
},
"-L6Tr4j05NV6BJKcaRSe": {
"List": "{'x': [0.03196, 0.01537], 'y': [0.96795, 0.96966], 'z': [0.05051, 0.04929]}",
"Index": "17362"
}
}
for key in data:
print(key, data[key])
另请参阅:
这篇关于使用Python解析Firebase JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文