jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

multifile output not creating yaml stream

Open achauvin-wish opened this issue 2 years ago • 1 comments

I have a jsonnet which outputs a json of the form {out.yaml: [{a:1},{b:2}]} (json simplified for this example).

When I run the command jsonnet -y -m. I do not get the intended yaml stream in the out.yaml file. Instead I get the json format output [{a:1},{b:2}]}.

Is this expected behavior? I also ran the same command but using jrsonnet (jrsonnet -y -m.) and I obtain the yaml stream as I would expect

achauvin-wish avatar Jan 04 '22 03:01 achauvin-wish

When you're using multi to output files that are not json (e.g. yaml), you have to choose a format for each file being output. In practice that means using std.exportYamlDoc or std.exportYamlStream to convert the value to a string (use the right function for the format you want) and then using -S when using --multi in order to avoid encoding that string as json.

sparkprime avatar Apr 13 '23 13:04 sparkprime