Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering JSON from API through jq in Python

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/

like image 369
JasperK Avatar asked Jun 20 '26 17:06

JasperK


1 Answers

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

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

like image 138
nicoco Avatar answered Jun 23 '26 08:06

nicoco