mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Not possible to render mapping with Int keys in YAML #262
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 @artemijan on GitHub (Jan 10, 2025).
when trying to render it, I get an error:
@StefMa commented on GitHub (Jan 10, 2025):
Seems it is not allowed to use numbers only in xml as a tag name.
See also https://www.w3.org/TR/xml/#NT-Name
However, you should be able to use
_1ora1... Which is, in return, in pkl a string 🙃@artemijan commented on GitHub (Jan 10, 2025):
I actually tried it also for a json and yaml. Output is the same. I need this for yaml file.
@HT154 commented on GitHub (Jan 10, 2025):
JSON requires string keys. I was less sure about YAML (1.2) and looked up the spec: non-string keys (including seq or map) are explicitly allowed, but many YAML implementations do not support them.
This includes Pkl's currently, which I think should be considered a bug. This construct is legal in both Pkl and YAML, so the renderer should accept it (at least for scalar types).
If you can accept numeric string keys, as a workaround you may be able to handle this at render time with a converter, e.g.:
@HT154 commented on GitHub (Jan 10, 2025):
Okay, PR open with the fix. You can also use render directives to get the desired output until this fix is released:
@bioball commented on GitHub (Jan 11, 2025):
Changing the title (this behavior is correct in XML and JSON).