-
I have the following class
and the following JSON which is a partial representation of User
I read this json in my pkl and use the deepToTyped to convert it into a User instance
How can someone amend the properties Mapping?
works, however, it wipes out the properties if they were there in JSON
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
My requirements is to ensure, both the remote properties & locally defined properties get merged into the final properties Mapping |
Beta Was this translation helpful? Give feedback.
-
At first I thought I could just set a default in the class
but this failed with an error
|
Beta Was this translation helpful? Give feedback.
-
This worked after I did the following change
to
removing the optionality |
Beta Was this translation helpful? Give feedback.
-
I haven't dug into this, but, it's probably because of these lines: https://github.com/apple/pkl-pantry/blob/b7d8b68eb980d3cb6f6babb16537580425419fd6/packages/pkl.experimental.deepToTyped/deepToTyped.pkl#L129-L132
This is probably a bug in |
Beta Was this translation helpful? Give feedback.
I haven't dug into this, but, it's probably because of these lines: https://github.com/apple/pkl-pantry/blob/b7d8b68eb980d3cb6f6babb16537580425419fd6/packages/pkl.experimental.deepToTyped/deepToTyped.pkl#L129-L132
properties: Mapping<String, String>?
is sugar for:properties: Mapping<String, String>? = Null(new Mapping<String, String> {})
Null(new Mapping<String, String> {})
is a different null than thenull
literal; they behave differently when amended.This is probably a bug in
deepToTyped
, feel free to create a GitHub issue for it (or submit a PR to fix it)