Skip to content

How to remove map entries from selected nested maps properties #2343

Closed Answered by mikefarah
james-lim-ev asked this question in Q&A
Discussion options

You must be logged in to vote
yq 'with(.. | select(kind == "map" and .type == "object"); 
    ([.field[].properties | keys] | flatten ) as $k | .properties |= omit($k) ) ' 
  • with(.. | select(kind == "map" and .type == "object"); <<exp>> will iterate over every type: object node
  • Then we need to get an array of the keys the we want to omit. ([.field[].properties | keys] | flatten ) and save that as $k
  • And finally we update the properties map to omit those keys .properties |= omit($k)

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

@mikefarah
Comment options

@james-lim-ev
Comment options

Answer selected by james-lim-ev
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