-
I have a YAML file that I converted into JSON using I need to convert this file back to YAML. Currently I use the command Is it possible to convert the file from YAML to JSON and back, so that the intermediary file in JSON is not an array, and the final YAML file is still a single file with multiple documents? Additional Information
JSON file that works with checkov:
JSON file that yq needs to convert it into YAML. YAML output similar to first example.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The 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 what you want is something like:
|
Beta Was this translation helpful? Give feedback.
-
@mikefarah I have the same problem with another tool. Many converters do this and spit out multiple JSON objects per file without wrapping them in an array:
It's not valid JSON but |
Beta Was this translation helpful? Give feedback.
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 - butyq
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 usesed
or something similar to replace line endings with---
.what you want is something like: