ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Incorrect `null` value for xml attributes when the expected field type is an array #6926

Open SasinduDilshara opened 2 months ago

SasinduDilshara commented 2 months ago

Code

import ballerina/data.xmldata;
import ballerina/io;

public function main() {
    xml a = xml `<a id="2">1</a>`;
    record {int[] id;}|error rec = xmldata:parseAsType(a);
    io:println(rec);
}

The output for the above code is {"id":null,"#content":1}. It should be an error message like incompatible types

SasinduDilshara commented 2 months ago

May be related to https://github.com/ballerina-platform/ballerina-library/issues/6924

SasinduDilshara commented 2 months ago

Similar issue is happen for following code as well.

A41|error a41 = xmldata:parseAsType(x4);
test:assertEquals(a41, {"B":{"#content":"Nested Content","b1":99,"b2":"45.67"}});