ballerina-platform / ballerina-library

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

NPE in Jsondata module when expected type is a union type #6927

Open SasinduDilshara opened 1 month ago

SasinduDilshara commented 1 month ago

Code

import ballerina/data.jsondata;
import ballerina/io;

type A43 record {|record{|int[]|int \#content; string...;|} B;|};

public function main() {
    A43|error a = jsondata:parseAsType({B: [1,2,3]});
    io:println(a);
}

Output

error: java.lang.NullPointerException {"message":"Cannot invoke "io.ballerina.runtime.api.types.Type.getTag()" because "this.rootArray" is null"}
        at ballerina.data.jsondata.0:parseAsType(json_api.bal:25)
           wso2.xml_data_prod.0:main(test_codes.bal:7)