Skip to content

Converting JSON to YAML using qa, without brackets in JSON #1185

Answered by mikefarah
epodegrid asked this question in Q&A
Discussion options

You must be logged in to vote

The yaml standard supports multiple documents in a single file, separated by ---; whereas the JSON standard does not. It looks like checkov works regardless, which is nice - but yq will not accept that document as input.

If you'd like to bring it back - best thing I can suggest is to output the JSON in single line format (set indent to 0), then push that through to checkov.

Then to parse it back into yq, you'll need to add yaml document separators --- between each document. This should be eas(ier) because each line is a JSON document. You could use sed or something similar to replace line endings with ---.

what you want is something like:

{"d": "doc 1"}
---
{"d": "doc 2"}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@epodegrid
Comment options

Answer selected by epodegrid
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants