We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
In (.[].children|.[])|=if has("color") then . else empty end, empty behaves different from regular values.
(.[].children|.[])|=if has("color") then . else empty end
empty
To Reproduce
Run jq '(.[].children|.[])|=if has("color") then . else empty end' foo.json, where foo.json is:
jq '(.[].children|.[])|=if has("color") then . else empty end' foo.json
[ { "name": "foo", "children": [{ "name": "foo.0", "color": "red" }] }, { "name": "bar", "children": [{ "name": "bar.0", "color": "green" }, { "name": "bar.1" }] }, { "name": "baz", "children": [{ "name": "baz.0" }, { "name": "baz.1" }] } ]
Output:
[ { "name": "foo", "children": [ { "name": "foo.0", "color": "red" } ] }, { "name": "bar", "children": [ { "name": "bar.0", "color": "green" } ] }, { "name": "baz", "children": [ { "name": "baz.1" } ] } ]
Expected behavior
I expected this output, which I can get by running del(.[].children[] | select(has("color") | not)).
del(.[].children[] | select(has("color") | not))
[ { "name": "foo", "children": [ { "name": "foo.0", "color": "red" } ] }, { "name": "bar", "children": [ { "name": "bar.0", "color": "green" } ] }, { "name": "baz", "children": [] } ]
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered:
This is duplicate of #2051.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Describe the bug
In
(.[].children|.[])|=if has("color") then . else empty end
,empty
behaves different from regular values.To Reproduce
Run
jq '(.[].children|.[])|=if has("color") then . else empty end' foo.json
, where foo.json is:Output:
Expected behavior
I expected this output, which I can get by running
del(.[].children[] | select(has("color") | not))
.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: