Open lnash94 opened 2 weeks ago
This issue is a blocker for the module http , jsondata APIs migration in u11. https://github.com/ballerina-platform/module-ballerina-http/pull/2168 And provide this support : https://github.com/ballerina-platform/ballerina-library/issues/4870#issuecomment-2262151011
The simplest version of the error
import ballerina/io;
import ballerina/data.jsondata;
public type User readonly & record {|
int id;
|};
public function main() returns jsondata:Error? {
json user2 = {id: 4012};
User r2 = check jsondata:parseAsType(user2);
io:println(r2);
}
We received an error for the below scenario as well
type DDPerson record {|
readonly int id;
|};
DDPerson rs = check jsondata:parseAsType({id: 10});
error: {ballerina}TypeCastError {"message":"incompatible types: 'error' cannot be cast to '(anydata|data.jsondata:Error)'"}
at ballerina.data.jsondata.0:parseAsType(json_api.bal:24)
Description: The below sample returns an error while parsing using jsondata:parserAsType(), this error occurred when given data type has data type with readonly ,
Steps to reproduce: Run the above given sample
Affected Versions: 2201.10.1 OS, DB, other environment details and versions:
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):