Package: jqfpy
jqfpyjq is too difficultjq 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).$catdata.json|jq'.apps | . as $$o | keys | map(select($$o[.].use))'["bar","boo","foo"]If you have python's knowledge, this is tiny oneliner, isn't it?$catdata.json|jqfpy'[k for k, opts in get("apps").items() if opts["use"]]'["foo","bar","boo"](get()is special function, like ajson.load(sys.stdin).get.)install$pipinstalljqfpyhow to usedescribe syntaxtodo.tutorialthis is jqfpy version ofjq's Tutorial$aliasjsonDATA="curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5'"#jq.$jsonDATA|jq'.'#jqfpy.$jsonDATA|jqfpy'get()'#jq.$jsonDATA|jq'.[0]'#jqfpy.$jsonDATA|jqfpy'get()[0]'#jq.$jsonDATA|jq'.[0] | {message: .commit.message, name: .commit.committer.name}'#jqfpy.$jsonDATA|jqfpy'd = get()[0]; {"message": get("commit/message", d), "name": get("commit/committer/name", d)}'#or$jsonDATA|jqfpy'{"message": get("0/commit/message"), "name": get("0/commit/committer/name")}'#jq.$jsonDATA|jq'.[] | {message: .commit.message, name: .commit.committer.name}'#jqfpy.$jsonDATA|jqfpy--squash'L = get(); [{"message": get("commit/message", d), "name": get("commit/committer/name", d)} for d in L]'#jq.$jsonDATA|jq'[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'#jqfpy.$jsonDATA|'L = get(); [{"message": get("commit/message", d), "name": get("commit/committer/name", d), "parents": [p["html_url"] for p in d["parents"]]} for d in L]'#or(usingh.pick)$jsonDATA|'L = get(); [h.pick("commit/message@message", "commit/committer/name@name", "parents[]/html_url@parents", d=d) for d in L]'additionalsother formats supportjqfpy is supporting other formats(but this is experimental feature)yamlltsvif you want to use yaml supported version. install via below command.$pipinstalljqfpy[yaml]and calling jqfpy with--input-format,-ioption and--output-format,-ooption.02data.yamlperson:name:fooage:20nickname:fool$cat02data.yaml|jqfpy-iyaml'get("person")'{"name": "foo","age": 20,"nickname": "fool"}$cat02data.yaml|jqfpy-iyaml-oltsv'get("person")'name:foo	age:20	nickname:foolhelper functionshelper functions are included.pick()omit()flatten()chunk()loadfile()dumpfile()pick()$cat02data.yaml|jqfpy-iyaml'h.pick("person/name", "person/age")'{"person": {"name": "foo","age": 20}}$cat02data.yaml|jqfpy-iyaml'h.pick("person/name@name", "person/age@age")'{"name": "foo","age": 20}omit()$cat02data.yaml|jqfpy-iyaml'h.omit("person/nickname")'{"person": {"name": "foo","age": 20}}flatten()$seq15|jqfpy--slurp-c'L = get(); [L, L]'[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]$seq15|jqfpy--slurp-c'L = get(); h.flatten([L, L], n=1)'[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]chunk()$seq110|jqfpy--slurp-c'h.chunk(get(), n=3)'[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]loadfile()$ls*.jsona.json b.json$echo'["a", "b"]'|jqfpy'{name: h.loadfile(f"{name}.json") for name in get()}'--hereand--relative-pathoptions.#see./x.json$jqfpy'h.loadfile("x.json")'a/b/main.json#see./a/b/x.json$jqfpy--herea/b/'h.loadfile("x.json")'a/b/main.json#see./a/b/x.json$jqfpy--relative-path'h.loadfile("x.json")'a/b/main.jsondumpfile()$ echo {"person0.json": {"name": "foo", "age": 20}, "person1.json": {"name": "bar}} | jqfpy '[h.dumpfile(v, fname) for fname, v in get().item()]' > /dev/nullindividual helper module with --additionalsmatch.pyimportredefmatch(rx,text):iftextisNone:returnFalsereturnre.search(rx,text)$catexamples/additionals/00data.json|jqfpy--additionals=./match.py'[d for d in get("constraint") if h.match("^1\..+", d.get("version"))]'[{"name": "github.com/Masterminds/vcs","version": "1.11.0"},{"name": "github.com/boltdb/bolt","version": "1.0.0"}]0.6.2catch up magicalimport 0.8.10.6.1fix--show-noneoption, always ignored, in 0.6.00.6.0add--show-none(default, if return value is None, doesn't write to stdout)add raw formatadd short option-aand-u(drop--ascii-outputasa-a)0.5.4change arguments order, h.dumpfile (#41)fix bug for get() (#37)0.5.3fix bug for h.dumpfile()0.5.2add h.loadfile() function  (#35)0.5.1h.dumpfile() with raw option0.5.0drop python 3.5yaml output, oneline string including hash, always quoted (#28)treat '/foo' as 'foo' (lstripped)add h.dumpfile() function  (#31)0.4.2support python 3.4custom additionals (--additionals option)new helpers -- h.flatten, h.flatten1 and h.chunk0.4.1ordered is default, when json loading0.4.0experimental ltsv supportadding helper functions (h.omit(), h.pick())extend get() function's functionrename option(--show-code-only to --show-code)0.3.2the future is dropped that showing help when calling with no arguments0.3.0experimental yaml format support0.2.0correct behaviours of--slurpand--unbufferedsupport accessing data by json pointer like formatcompact output supportmultiple files supportexec code only once0.1.0adding some optionsnocode is same asjq .(js == jq .)showing pycode when error is raised0.0.1first release