-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Empty result is decoded as an empty string even when output
is set to json
#689
Comments
Exactly, the option In case of changing this behaviour to return I would like to change it, and either reject the promise or radically return an empty object. Any extra thoughts @mackermans? Thanks for opening the issue @grenik, I believe isn't the first confusing case. |
Thanks for raising this, @grenik. @davesnx I opened the PR thinking that I don't think the alternatives are better, though:
Could we consider a new output mode (JS)? That means we would need to accept that the current case described by @grenik will continue to exist. |
Indeed, the empty string is an expected result from jq saying that there's no filters/matches with your query. Either by outputting json or strings. |
Many thanks for quick answers and even a solution! Totally agree with the following points:
Option 1: Solution with
|
If running a jq filter produces an empty result, the result is an empty string (
''
) even if theoutput
option is set tojson
.It may be a bit confusing because an empty string is also a different valid result (see examples below).
I believe that
undefined
would be a better option because it is used neither in JSON nor in JQ.The text was updated successfully, but these errors were encountered: