Skip to content

How to replace if-then-else? #710

Answered by mikefarah
jtyr asked this question in Q&A
Feb 3, 2021 · 3 comments · 3 replies
Discussion options

You must be logged in to vote

Wow this is a complex example - and the sample is quite large. I think you can do this without walk or if by filtering withing the delete expression.

For instance instead of:

walk(if type == "object" then del(.status,.creationTimestamp,.generation,.selfLink,.uid,.resourceVersion,.managedFields) else . end

you could (snippet):

del(.. | select(tag == "!!map") | (.status, .creationTimestamp))

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jtyr
Comment options

Answer selected by mikefarah
Comment options

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

@jtyr
Comment options

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