How to remove an empty map from YAML? #882
-
I need to remove an empty map from a YAML. My YAML code looks like this: apiVersion: route.openshift.io/v1
kind: Route
metadata:
annotations: {}
creationTimestamp: "2021-03-24T13:16:10Z" I need to remove My desired output: apiVersion: route.openshift.io/v1
kind: Route
metadata:
creationTimestamp: "2021-03-24T13:16:10Z" Anybody can helps me? https://stackoverflow.com/questions/68264327/yq-how-to-remove-an-empty-map-from-yaml |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This example works!!! yq e 'del(.metadata.annotations | select(length==0))' yaml |
Beta Was this translation helpful? Give feedback.
-
What if |
Beta Was this translation helpful? Give feedback.
This example works!!!
yq e 'del(.metadata.annotations | select(length==0))' yaml