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

[Bug]: toJson not working properly for Xml values #43764

Closed
SasinduDilshara opened this issue Jan 23, 2025 · 2 comments
Closed

[Bug]: toJson not working properly for Xml values #43764

SasinduDilshara opened this issue Jan 23, 2025 · 2 comments
Labels
Reason/Invalid Issue is invalid. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@SasinduDilshara
Copy link
Contributor

SasinduDilshara commented Jan 23, 2025

Description

import ballerina/io;

public function main() {
    xml a = xml `<a>hello</a>`;
    io:println(a.toJson());
}

The above code gives following invalid result

<a>hello</a>

Affected Version(s)

2201.10.3

Related area

-> Compilation

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jan 23, 2025
@SasinduDilshara SasinduDilshara added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. and removed needTriage The issue has to be inspected and labeled manually labels Jan 23, 2025
@MaryamZi
Copy link
Member

Can you please mention why you think this is incorrect?

The definition of toJson says

A value of type xml is converted into a string as if by the toString function.

and the behaviour seems to be in-line with this?

import ballerina/io;

public function main() {
    xml a = xml `<a>hello</a>`;
    io:println(a.toJson()); // <a>hello</a>
    io:println(a.toJson() == a.toString()); // true
}

Copy link

github-actions bot commented Feb 6, 2025

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@MaryamZi MaryamZi added the Reason/Invalid Issue is invalid. label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason/Invalid Issue is invalid. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

3 participants