Skip to content

Irregular objects selection #325

Answered by TomWright
wino45 asked this question in Q&A
May 31, 2023 · 6 comments · 2 replies
Discussion options

You must be logged in to vote

There is something strange going on with the error output that I've been meaning to look into, but this would be throwing an error when it see's an object without the name.

You can get this working by adding a ? after the "optional" property name, e.g:

echo '{ "users": [ { "name": "Tom" }, { "wrong_name": "Jim" } ] }' | dasel -r json 'users.all().name?'
"Tom"

This is documented here: https://daseldocs.tomwright.me/functions/property

If any argument ends with a ?, that lookup is considered optional and dasel will continue if that property is not found.

Replies: 6 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by TomWright
Comment options

You must be logged in to vote
2 replies
@TomWright
Comment options

@TomWright
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants