Skip to content
New issue

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

`.a[] |= empty' produces odd results #2397

Closed
ikegami opened this issue Jan 11, 2022 · 2 comments · Fixed by #2133
Closed

`.a[] |= empty' produces odd results #2397

ikegami opened this issue Jan 11, 2022 · 2 comments · Fixed by #2133

Comments

@ikegami
Copy link

ikegami commented Jan 11, 2022

I don't know what this should output, but 2 isn't it.

$ jq -nc '{"a":[1,2,3]} | .a[] |= empty'
{"a":[2]}

This is the result of the following property of |=:

If the right-hand side outputs no values (i.e., empty), then the left-hand side path will be deleted, as with del(path).

This property also introduces this annoying difference:

$ jq -nc '{"a":[1,2,3]} | .a = ( .a | empty )'

$ jq -nc '{"a":[1,2,3]} | .a |= empty'
{}
@emanuele6
Copy link
Member

duplicate of #2051.

@ikegami
Copy link
Author

ikegami commented Jan 11, 2022

Indeed, so I'll close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants