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 result when nested arrays are present in `data.xmldata` module #7305

Open SasinduDilshara opened 3 weeks ago

SasinduDilshara commented 3 weeks ago

Description

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

type A record {
    string[] name;
    int[] id;
};

function test() returns error? {
    string validXmlValue = string `<A><id>1</id><name>John</name><id>1</id><name>John</name><user><id>1</id><name>John</name><id>2</id><name>John2</name></user></A>`;
    A validatedOutput = check xmldata:parseString(validXmlValue);
    io:println(validatedOutput); // output: {"name":["John","John"],"id":[1,1],"user":{"id":2,"name":"John2"}}
}

public function main() returns error? {
    check test();
}

The expected output is {"name":["John","John"],"id":[1,1],"user":[{"id":1,"name":"John"}, {"id":2,"name":"John2"}]}

Steps to Reproduce

$Description

Version

2201.10.2

Environment Details (with versions)

No response