jq for pythonista
Project description
jq is too difficult
jq is too difficult, at least for me.
For example, extracting key-name when use is true only, from below JSON data.
{
"apps": {
"foo": {
"use": true
},
"bar": {
"use": true
},
"boo": {
"use": true
},
"bee": {
"use": false
}
}
}
What is jq’s answer? (taking over 30 minutes, my past challenges).
$ cat data.json | jq -r '.apps | . as $$o | keys | map(select($$o[.].use))'
[
"bar",
"boo",
"foo"
]
If you have python’s knowledge, this is tiny oneliner, isn’t it?
$ cat data.json | jqfpy '[k for k, opts in get("apps").items() if opts["use"]]'
[
"foo",
"bar",
"boo"
]
(get() is special function, like a json.load(sys.stdin).get.)
install
pip install jqfpy
tutorial
todo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jqfpy-0.0.1.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for jqfpy-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9f66ea69672d1ce2c566838177cfacc61c444ddcfc018f8e2eb1878425567b8 |
|
MD5 | 1d8a943732286fb9ed02d07d9ea3bfb5 |
|
BLAKE2b-256 | c0ef8b89b5169fc23760a32015f06887de5c4d1b6534b15a289d12b0d35d8ffd |