【发布时间】:2020-04-06 13:15:27
【问题描述】:
我需要通过 API 请求一个 PG 数据库,我正在使用 Flask requests 包:
payload = {'key':'**', 'schema':'**', 'table':'testh','where_clause':'0', 'liste_fields':'*'}
r = requests.get('https://myapi/', params=payload, verify=False)
我需要在 JSON 中获取我的 testh 表存储的所有内容,但函数 r.json() 让我得到这个无效的 JSON:
{'id': {'0': '1', '1': '2', '2': '3', '3': '4'}, 'brand': {'0': 'apple', '1': 'microsoft', '2': 'google', '3': 'amazon'}}
我需要一个 JSON 格式:{0: {id:'2', brand:'apple}, 1:{id:'2', brand:'microsoft}, ....}
【问题讨论】:
标签: json flask python-requests