Comments (5)
Nevermind, I can reproduce it now, I was using the wrong binary; sorry! ^^
Anyway, I think this was only not erroring because try
was bugged in many ways in jq 1.6
. Especially when used in combination with foreach
which was very annoying. :-(
If you try null | ascii_downcase
even in jq 1.6
it will error. And in that command, it is supposed to error.
I am not sure I understand what the intent of that jq
command is supposed to be.
If you want to only keep the objects that either don't contain .baz
or that have a .baz
equal to null
or ""
, I suggest using this instead:
jq 'del(.[] | select(.baz | IN(null, "") | not))'
# alternatively
jq 'del(.[] | select((.baz // "") != ""))'
jq 'map(select(.baz | IN(null, "")))'
jq 'map(select((.baz // "") == ""))'
If you want to only remove objects that contain a "baz"
in general, you can use:
jq 'del(.[] | select(has("baz")))'
# or, if you want to also keep objects with {"baz":null}
jq 'del(.[] | select(.baz != null))'
from jq.
@gursewak1997
I cannot reproduce that command not failing in jq 1.6
.
The exception is triggered by {"foo":"bar"} | .baz
returning null
succesfully (since there is not a "baz"
key in the object), and then null | ascii_downcase
being called, and ascii_downcase
is not in a try
block.
ascii_downcase
errors for non-string inputs in both jq 1.6
, jq 1.7
, and jq 1.7.1
.
{"foo":"bar"} | .baz
retruns null
in both jq 1.6
, jq 1.7
, and jq 1.7.1
. .baz
would only error if the input is neither null
nor an object. If the specified key is missing from the input object, or if the input is null
, it just returns null
in all versions of jq
, it does not error.
from jq.
I don't get what is the point of using ascii_downcase == ""
either.
from jq.
See #1859, #2750. This is working as intended in 1.7. In 1.6 try catches the error of ascii_downcase but it should not.
from jq.
@emanuele6 For posterity, note the example here is just a minimal reproducer. The real world use case it was boiled down from can be seen in coreos/fedora-coreos-config#2797 (where we worked around it).
from jq.
Related Issues (20)
- Are there any errors in the ICU License description in the "decNumber"? HOT 4
- `match(...)` silently crashes when nothing is found HOT 3
- `scan("(a)(b)")` returning an array is not documented
- Unable to install jp using poetry or pip HOT 1
- fromdateiso8601 not inverse of todateiso8601 HOT 5
- The jq returned wrong json after updating based on select. HOT 1
- capture returns inconsistent results for optional named group HOT 2
- need command line options to print path and key values of JSON file HOT 7
- Please add nullish coalescing operator "??" to JQ? HOT 3
- Cannot select sub-field that has a dash in the name of the field HOT 1
- compile error HOT 10
- Multiplying -1 with 0 must result 0, not -0 HOT 2
- ~/.jq is not sourced on windows
- Unexpected output HOT 1
- Null bytes are handled inconsistently HOT 5
- tonumber doesn't work on `true` or `false` HOT 4
- "color for object keys" from JQ_COLORS doesn't seem to be respected HOT 4
- `range/3` behaviour when $init and $upto arguments are not numbers HOT 4
- Regular expression alternation (|) used with quantifier (* or +) returns inconsistent results when first alternative is able to match an empty string HOT 3
- Create Multi Smaller Files From a Big Json File HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jq.