Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xsi:nil Attribute is not supported in the xmldata Module #7462

Closed
daneshk opened this issue Dec 11, 2024 · 0 comments · Fixed by ballerina-platform/module-ballerina-xmldata#551

Comments

@daneshk
Copy link
Member

daneshk commented Dec 11, 2024

Description

When converting XML to JSON using the xmldata:toJson() function, it returns empty strings for values of fields where the attribute xsi:nil="true" is present. These values should be null.

Steps to Reproduce

Consider the following Ballerina code:

import ballerina/xmldata;
import ballerina/io;

public function main() returns error? {
    xml x1 = xml `<name>Sherlock Holmes</name>
                  <details xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <author xsi:nil="true"/>
                    <language>English</language>
                  </details>`;
    json jsonValue = check xmldata:toJson(x1, {preserveNamespaces: false});
    io:println(jsonValue.toJsonString());
}

Expected output:

{"name":"Sherlock Holmes", "details":{"author":null, "language":"English"}}

Actual output:

{"name":"Sherlock Holmes", "details":{"author":"", "language":"English"}}

Reference: https://github.com/wso2-enterprise/internal-support-ballerina/issues/854

Version

Latest

Environment Details (with versions)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant