Filtering JSON from API through jq in Python

懵懂的女人 提交于 2019-12-11 13:18:52

问题


I'm trying to filter out the field "name" to store in a file. I'm filtering like so:

r =requests.get('https://api.spotify.com/v1/albums/70yMNdgyIj9SrQXFmdJKx9', 
headers=headers)

print(jq(".[name]").transform(json.loads(r)))

I get the error: print(jq(".[name]").transform(text=r)) TypeError: 'module' object is not callable

Any help on the matter? The documentation for jq python bindings is not very clear to me https://pypi.org/project/jq/


回答1:


As the exception message states, you are trying to call a module.

You have probably used import jq instead of from jq import jq.



来源:https://stackoverflow.com/questions/49976488/filtering-json-from-api-through-jq-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!