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

Invalid error for readonly record field in data.jsondata module in parseAsType API #7259

Closed
SasinduDilshara opened this issue Oct 14, 2024 · 3 comments · Fixed by ballerina-platform/module-ballerina-data.jsondata#46

Comments

@SasinduDilshara
Copy link
Contributor

SasinduDilshara commented Oct 14, 2024

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

type DDPerson record {|
    readonly int id;
|};

public function main() returns error? {
    json user2 =  {"id": 4012};
    DDPerson r2 = check jsondata:parseAsType(user2);
    io:println(r2.id);
}

The above code give following error

error: {ballerina}TypeCastError {"message":"incompatible types: 'error' cannot be cast to '(anydata|data.jsondata:Error)'"}
        at ballerina.data.jsondata.0:parseString(json_api.bal:33)
           wso2.jsontest.0:main(main.bal:10)
@lnash94
Copy link
Member

lnash94 commented Oct 15, 2024

This issue is a blocker for the module http , jsondata APIs migration in u11. ballerina-platform/module-ballerina-http#2168
And provide this support : #4870 (comment)

@SasinduDilshara SasinduDilshara changed the title Invalid error for readonly record field in data.jsondata module Invalid error for readonly record field in data.jsondata module in parseAsType API Oct 28, 2024
@SasinduDilshara
Copy link
Contributor Author

SasinduDilshara commented Oct 28, 2024

ballerina-platform/module-ballerina-data.jsondata#46 Will fix this issue for the parseAsType API which is the blocker for the module http.

The same issue occurs for the parseString API (Currently not a blocker) is track by #7302

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.

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