3 ms·
Sometimes, for extremely simple uses, when I don't want the hassle of selecting a Docker container that has jq, I'll just use a Python oneliner so I don't have
by rpigab 3y ago
Sometimes, for extremely simple uses, when I don't want the hassle of selecting a Docker container that has jq, I'll just use a Python oneliner so I don't have to learn extra syntax, can use Python's list comprehensions, etc:
<<< '{"a":"b", "c":"d"}' python3 -c 'import json,sys;print(json.loads(sys.stdin.read())["c"])'
This also works with a Python script with more lines if I need to add complexity or readability, or any feature, API calls, etc.
- gigatexal 3y agoI’ve done this too. I almost went as far as creating my own version of fx with it but then decided like AWK if I wanted to do something really fancy I’d just write up a script or do that << EOF thing and do the code in line