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 #7259

Open
SasinduDilshara opened this issue Oct 14, 2024 · 1 comment
Open

Comments

@SasinduDilshara
Copy link

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

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

public function main() returns error? {
    string user2 = string `{"id": 4012}`;
    DDPerson r2 = check jsondata:parseString(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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants