Jsonnet: Document -S (--string) in language reference (and maybe tutorial, too).

Created on 18 Oct 2020  路  6Comments  路  Source: google/jsonnet

Not much else to say.

$ jsonnet --version && cat test.jsonnet && echo  && jsonnet test.jsonnet 
Jsonnet commandline interpreter v0.16.0
local wrapper = [
  {
    some_prop: true
  }
];

std.manifestYamlDoc(wrapper)
"- \"some_prop\": true"
documentation

Most helpful comment

Try passing the --string flag to the _jsonnet_ tool.

All 6 comments

Try passing the --string flag to the _jsonnet_ tool.

Yep. Jsonnet formats the output as JSON by default. The function manifestYamlDoc returns a string, so the output is formatted as JSON string which contains your YAML. When you pass -S/--string, the output string is printed verbatim.

Do you mind pointing me to where in the documentation it says this?

I have been going off this and it did not mention any of this https://jsonnet.org/ref/stdlib.html

image

That said, we should probably document -S option in reference and/or tutorial. It is described in https://jsonnet.org/articles/output-formats.html, but it's so important that we should mention it in other places too.

Thanks for the response. A line or two of options docs would have saved me an hour of debugging there

I think we can still document it better. This is a pretty basic feature and should be mentioned in the tutorial. Reopening.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nnmrts picture nnmrts  路  9Comments

benley picture benley  路  9Comments

mateuszpieniak picture mateuszpieniak  路  5Comments

ant31 picture ant31  路  6Comments

mbrukman picture mbrukman  路  5Comments