Skip to content
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

Support for multiple YAML documents / concatenated JSON #14

Open
sclevine opened this issue Sep 22, 2020 · 4 comments
Open

Support for multiple YAML documents / concatenated JSON #14

sclevine opened this issue Sep 22, 2020 · 4 comments

Comments

@sclevine
Copy link
Owner

Notes:

YAML:

a: 1
---
b: 2
---
c: 3

JSON:

{"a": 1}
{"b": 2}
{"c": 3}

(Also allowed: {"a": 1}{"b": 2}{"c": 3})

TOML and HCL should error.
Should we provide a flag to select a document by index?

@sclevine
Copy link
Owner Author

CC: @nebhale

@webwurst
Copy link

Until the feature is added here, the following alternative worked for me using the yq binary:

$ cat << EOF > ./example.yaml
a: 1
---
b: 2
---
c: 3
EOF

$ cat ./example.yaml | yq -o json | jq -c
{"a":1}
{"b":2}
{"c":3}

@jghiloni
Copy link

@sclevine i hit this today, thought i might look at it. could a second flag be provided to output as concatenated json or as json array?

@sclevine
Copy link
Owner Author

Hey @jghiloni, sounds reasonable to me, as long as the behavior without the extra flag is as described above.

Could also make sense to have it work more generically. The flag could mean "output multiple documents as a list" when converting from YAML to any other format. In the future, a different flag could do the inverse ("interpret a list a multiple documents").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants