-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FQ fails to parse YAML files containing multiple documents #1087
Comments
Related to #1087 TODO: Support encode via option?
Hi, thanks for the report! That should be possible to fix but i'm a bit unsure how it should work. I did a draft PR #1088 that decodes all documents into an array but then these two yaml files will produce the same jq value: ---
hi: bye
---
doesnt: work - hi: bye
- doesnt: work Maybe not a big deal. But maybe the yaml format, |
In my case I’m dealing with kubernetes manifests and helm template output - eg: https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/experimental-install.yaml It’s useful to do analysis on kinds. Right now I have to use yq to parse the multi document yaml into json and then use fq. Eg: cat foo.yaml | yq e -o json | fq . Would be nice to get rid of yq entirely. That’s my last missing use case |
It would also be nice if it preserved ordering eg cat experimental-install.yaml | fq -rc to_yaml Was a multi document output ideally with stable key ordering. I know that might be tough with go. |
Now the draft PR has has a If you have go installed you should be albe to try it out using: $ go run github.com/wader/fq@yaml-multi-document -nr '[1,2,3] | to_yaml({multi_document: true})'
1
---
2
---
3
Yes preserving order in object is a bit tricky as it works now. Another thing that won't work is comments in yaml, they will be stripped. It's a bit unclear how that would work. |
What version are you using (
fq -v
)?How was
fq
installed?FQ was installed with Nix on macOS.
Can you reproduce the problem using the latest release or master branch?
I have verified that this issue occurs in version 0.13.0. I haven't checked the master branch, but I can try if needed.
What did you do?
I attempted to parse a YAML file containing multiple documents using
fq
.To demonstrate:
What result did you expect?
I expected
fq
to parse the YAML file and output each document separately as a stream or in an array format, similar to how it handles a single document.What did you see instead?
The text was updated successfully, but these errors were encountered: