Skip to content

Any way to force YAML value as quoted string? #829

Answered by HT154
djarnis73 asked this question in Q&A
Discussion options

You must be logged in to vote

The solution here is actually extremely straightforward: If a value is a String in Pkl it will be a string in the resulting YAML!

If all keys under options.thresholds should have string values, then you want this:

renderer = new YamlRenderer {
  converters {
    ["options.thresholds.*"] = (v) -> v.toString()
  }
}

Pkl's YAML renderer knows when to wrap a string value in quotes to avoid a collision with other YAML types (number, boolean, etc.). This is also why the attempt to add !!str results in a quoted string.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by djarnis73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants