这是对我之前提出的一个问题的更具体的补充。基本上,我试图从处理GET请求后收到的JSON文本块中提取特定数据。在限制到只包含项目之后(通过使用目录项()方法),我只剩下以下JSON数据(有很多,但这只是一个示例):
[('response',
{'count': 84,
'users': [{'location_id': 123456,
'acx_audit': None,
'flash_backup_url': u'',
'flash_backup_url_secure': u'',
'flash_click_variable': None,
'folder': None,
'format': u'url-json',
'height': 1,
'id': 36619222,
'is_prohibited': False,},
{'location_id': 5556667,
'acx_audit': None,
'flash_backup_url': u'',
'flash_backup_url_secure': u'',
'flash_click_variable': None,
'folder': None,
'format': u'url-json',
'height': 1,
'id': 4567777,
'is_prohibited': False,}
我尝试提取的数据是这些对象中每一个的“id”号(而不是“location\u id”),并将收集到的所有这些号放入一个数组中。不过,我有点纠结,因为我不习惯使用像这样的大JSON数据结构,其中有相互嵌套的字典和数组。我是否也需要运行一个循环来完成这个任务?你知道吗
任何帮助都将不胜感激,因为我现在被困住了。谢谢。你知道吗
可以按以下方式进行(涉及一些严格的条件检查,以避免引发异常)
相关问题 更多 >
编程相关推荐