You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This does seem unexpected and prone to mistakes, as it has a completely different meaning. There are tests expecting this behaviour, for example input and output.
The following XML could be the expected behaviour for me in this particular case. But honestly, lists and XML can be tricky. How would you deal with adminIdList = null in this case? And how would that solution compare to that of an empty list?
The problem here is that the standard representation of a list of things in XML is to write out the elements consecutively. This is actually quite central in the XML spec.
Given
import "pkl:xml"
class Foo {
bar: Int
}
elements: Listing<Foo> = new {
new { bar = 1 }
new { bar = 2 }
}
output {
renderer = new xml.Renderer {}
}
It is admittedly awkward that 1, 2, and 3 come out as 123, which is "just" because Int is a primitive type. That said, if you need repetition of the element tag, or even just line breaks to separate elements of the list, the solution is to use converters.
This was discovered during evaluation, and is not a case we actually need supported. It does feel unexpected and just thought it was worth mentioning.
Given the following
example.pkl
file:We can produce the following json file:
However, when we try to produce the XML representation of this we get:
This does seem unexpected and prone to mistakes, as it has a completely different meaning. There are tests expecting this behaviour, for example input and output.
The following XML could be the expected behaviour for me in this particular case. But honestly, lists and XML can be tricky. How would you deal with
adminIdList = null
in this case? And how would that solution compare to that of an empty list?The properties renderer just bails out for this case, which could also be reasonable.
The above has been tested using the following versions:
Pkl 0.25.3 (Linux 5.15.0-1053-aws, native)
Pkl 0.26.0-dev+3a31188 (Linux 5.4.0-177-generic, native)
The text was updated successfully, but these errors were encountered: