How can I write the Pkl to produce YAML output that includes the 'default' key as shown above?
list:
default:
value: dummy1
mykey:
value: dummy2
Originally created by @kaniza on GitHub (Dec 25, 2024).
I'm using Pkl version 0.27.1 on macOS.
```
% pkl --version
Pkl 0.27.1 (macOS 15.1, native)
```
I want to write Pkl that produces YAML output like the following, but I'm having trouble figuring out how to do it.
```
list:
default:
value: dummy1
mykey:
value: dummy2
```
I understand that when I write Pkl as shown below, 'default' is omitted from the output by specification.
``` sample.pkl
list {
default {
value = "dummy1"
}
mykey {
value = "dummy2"
}
}
```
```
$ pkl eval -f yaml sample.pkl
list:
mykey:
value: dummy2
```
So, I tried enclosing 'default' in backticks, but the result remained the same.
``` sample.pkl
list {
`default` {
value = "dummy1"
}
mykey {
value = "dummy2"
}
}
```
```
$ pkl eval -f yaml sample.pkl
list:
mykey:
value: dummy2
```
How can I write the Pkl to produce YAML output that includes the 'default' key as shown above?
```
list:
default:
value: dummy1
mykey:
value: dummy2
```
You would need to either a) define a class with a property default or b) use Mapping with key "default". You're (implicitly) using Dynamic here, which has a property default that's marked hidden.
@HT154 commented on GitHub (Dec 25, 2024):
You would need to either a) define a class with a property `default` or b) use `Mapping` with key `"default"`. You're (implicitly) using `Dynamic` here, which has a property `default` that's marked `hidden`.
list = new Mapping {
["default"] {
value = "dummy1"
}
["mykey"] {
value = "dummy2"
}
}
Using this approach, the "default" key is no longer hidden, and the YAML output is as expected:
list:default:value:dummy1mykey:value:dummy2
Thanks for the guidance!
@kaniza commented on GitHub (Dec 25, 2024):
Here's the updated Pkl code that worked:
```pkl
list = new Mapping {
["default"] {
value = "dummy1"
}
["mykey"] {
value = "dummy2"
}
}
```
Using this approach, the "default" key is no longer hidden, and the YAML output is as expected:
```yaml
list:
default:
value: dummy1
mykey:
value: dummy2
```
Thanks for the guidance!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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!