Dear YQ, Why do you eat my Comments? #965
-
Dear YQ, I have tried many permutations of your command, and yet; no joy. I would like to nest an entire YAML file within a single object, and I can't seem to get my point across. How can I satiate your hunger? Are you not entertained? I attempt the following cat test.yaml <<'EOF'
# Here's the first comment
first: 'first value'
# Here's the second comment
second: 'second value'
# Here's the third comment
third: 'third comment'
EOF
yq e '{"prefix":.}' test.yaml And you still give me prefix:
first: 'first value'
# Here's the second comment
second: 'second value'
# Here's the third comment
third: 'third comment' How do I get you to leave my comments alone? Sincerely Yours, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Dear confused developer, I am greedily eating your first comment because I think it's a document header (its pre-processed as part of a workaround/hack for a go-yaml issue). My appetite is never sated, however you can force me not to eat you header by:
Sincere apologies, |
Beta Was this translation helpful? Give feedback.
-
Hi I came across this issue today, my use case is trying to parse a docker-compose.yml and get a list of services name. For example: services:
# This is a
A:
image: repo/A
# This is b
B:
image: repo/B
# This is c
C:
image: repo/C I was running
Is there any way to get rid of it ? |
Beta Was this translation helpful? Give feedback.
Dear confused developer,
I am greedily eating your first comment because I think it's a document header (its pre-processed as part of a workaround/hack for a go-yaml issue).
My appetite is never sated, however you can force me not to eat you header by:
Sincere apologies,
yq