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]: convertJSON function in the JsonInternalUtils is not working correctly for string types. #42064

Closed
SasinduDilshara opened this issue Jan 30, 2024 · 1 comment · Fixed by #42079
Assignees
Labels
Lang/JSON Type `json` related issues Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Milestone

Comments

@SasinduDilshara
Copy link
Contributor

Description

public static Object convertJSON(Object jsonValue, Type targetType) {
  targetType = TypeUtils.getImpliedType(targetType);
  Type matchingType;
................
  case TypeTags.STRING_TAG:
                  if (jsonValue instanceof BString) {
                      return jsonValue;
                  }
                  return jsonValue.toString();
.............
}

This is the current implementation of the convertJSON function in the JsonInternalUtils.
This is wrong. This should be corrected as following.

public static Object convertJSON(Object jsonValue, Type targetType) {
  targetType = TypeUtils.getImpliedType(targetType);
  Type matchingType;
................
  case TypeTags.STRING_TAG:
                  if (jsonValue instanceof BString) {
                      return jsonValue;
                  }
                  return <convert jsonvalue to BString>;
.............
}

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jan 30, 2024
@SasinduDilshara SasinduDilshara added Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Lang/JSON Type `json` related issues and removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jan 30, 2024
@HindujaB HindujaB self-assigned this Jan 31, 2024
@github-project-automation github-project-automation bot moved this from PR Sent to Done in Ballerina Team Main Board Feb 12, 2024
Copy link

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.

@HindujaB HindujaB added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Feb 13, 2024
@warunalakshitha warunalakshitha added this to the 2201.9.0 milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lang/JSON Type `json` related issues Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants