The spec has defined https://ballerina.io/spec/lang/master/#ToString for tagged data types. Do we need to just call value:toString when value:toJson is called on tagged data values or what should be done here?
Suggested Labels:
spec/undefined
Code sample that shows issue:
import ballerina/lang.regexp;
import ballerina/io;
public function main() {
regexp:RegExp regExp = re `AB+C*D{1,4}`;
json jsonVal = regExp.toJson();
io:println(jsonVal);
}
currently gives
Running executable
error: {ballerina/lang.value}ConversionError {"message":"'anydata & readonly' value cannot be converted to 'json'"}
at ballerina.lang.value.0:toJson(value.bal:262)
reg:main(reg.bal:6)
Description:
Though
value:toJson
has mentioned about table and xml type anydata values, it does not mention how to handle tagged data values such as values of typelang.regexp:RegExp
. https://github.com/ballerina-platform/ballerina-spec/blob/c88701b369d1266eb2a31708ec046f56aa8ca9da/lang/lib/value.bal#L117-L132The spec has defined https://ballerina.io/spec/lang/master/#ToString for tagged data types. Do we need to just call
value:toString
whenvalue:toJson
is called on tagged data values or what should be done here?Suggested Labels:
spec/undefined
Code sample that shows issue:
currently gives
Related Issues:
https://github.com/ballerina-platform/ballerina-lang/issues/42070