mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
How to Include 'default' Key in YAML Output #259
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kaniza on GitHub (Dec 25, 2024).
I'm using Pkl version 0.27.1 on macOS.
I want to write Pkl that produces YAML output like the following, but I'm having trouble figuring out how to do it.
I understand that when I write Pkl as shown below, 'default' is omitted from the output by specification.
So, I tried enclosing 'default' in backticks, but the result remained the same.
How can I write the Pkl to produce YAML output that includes the 'default' key as shown above?
@HT154 commented on GitHub (Dec 25, 2024):
You would need to either a) define a class with a property
defaultor b) useMappingwith key"default". You're (implicitly) usingDynamichere, which has a propertydefaultthat's markedhidden.@kaniza commented on GitHub (Dec 25, 2024):
@HT154 Thank you, I'll try.
@kaniza commented on GitHub (Dec 25, 2024):
Here's the updated Pkl code that worked:
Using this approach, the "default" key is no longer hidden, and the YAML output is as expected:
Thanks for the guidance!