I encountered an error while attempting to define a nested mapping:
│ Expected value of type `Mapping`, but got type `String`.
│ Value: "attributes1 value"
│
│ 1 | nestedRecord: Mapping<String, Mapping<String, String>>?
│ ^^^^^^^^^^^^^^^^^^^^^^^
Does pkl support nested mappings i.e.Mapping<String, Mapping<String, String>>? If so, how should I define this structure correctly?
Originally created by @jjuliano on GitHub (Nov 28, 2024).
I want to define a nested mapping `nestedRecord` with the following structure:
- The outer mapping has `String` keys (e.g., `record1`, `record2`), each representing a record.
- The value for each key is an inner mapping, which itself maps `String` attribute names (e.g., `attrib1`, `attrib2`, `attrib3`) to their `String` values.
For example:
```
nestedRecord: Mapping<String, Mapping<String, String>>
```
With this, `nestedRecord` might look like:
```
nestedRecord {
["record1"] {
["attrib1"] = "attrib1 value"
["attrib2"] = "attrib2 value"
["attrib3"] = "attrib3 value"
}
["record2"] {
["attrib1"] = "attrib1 value"
["attrib2"] = "attrib2 value"
["attrib3"] = "attrib3 value"
}
}
```
I encountered an error while attempting to define a nested mapping:
```
│ Expected value of type `Mapping`, but got type `String`.
│ Value: "attributes1 value"
│
│ 1 | nestedRecord: Mapping<String, Mapping<String, String>>?
│ ^^^^^^^^^^^^^^^^^^^^^^^
```
Does pkl support nested mappings i.e.`Mapping<String, Mapping<String, String>>`? If so, how should I define this structure correctly?
sorry, I made a syntax error, it does work. I have the attributes directly on the nestedRecord. We can close this now.
@jjuliano commented on GitHub (Nov 29, 2024):
sorry, I made a syntax error, it does work. I have the attributes directly on the nestedRecord. We can close this now.
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 @jjuliano on GitHub (Nov 28, 2024).
I want to define a nested mapping
nestedRecordwith the following structure:Stringkeys (e.g.,record1,record2), each representing a record.Stringattribute names (e.g.,attrib1,attrib2,attrib3) to theirStringvalues.For example:
With this,
nestedRecordmight look like:I encountered an error while attempting to define a nested mapping:
Does pkl support nested mappings i.e.
Mapping<String, Mapping<String, String>>? If so, how should I define this structure correctly?@odenix commented on GitHub (Nov 28, 2024):
It does, and your syntax looks correct to me. I might be able to help if you posted a reproducer.
@jjuliano commented on GitHub (Nov 29, 2024):
sorry, I made a syntax error, it does work. I have the attributes directly on the nestedRecord. We can close this now.