Last active
June 20, 2022 16:39
-
-
Save sonnyksimon/d23fa2c51402592f4048f09c1fa4d9c7 to your computer and use it in GitHub Desktop.
Python JQ in windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import json | |
def applyjqtxt(filter, text): | |
echo = subprocess.Popen(('echo', text), stdout=subprocess.PIPE) | |
output = subprocess.check_output(('jq', filter), stdin=echo.stdout) | |
echo.wait() | |
return output | |
def applyjq(filter, data): | |
text = json.dumps(data) | |
output = applyjqtxt(filter, text) | |
return json.loads(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment