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

Getting string index out of range error when invoking copybook:toJson API #5848

Closed
MohamedSabthar opened this issue Dec 1, 2023 · 0 comments · Fixed by ballerina-platform/module-ballerinax-copybook#35
Assignees
Labels
module/copybook Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@MohamedSabthar
Copy link
Member

Description:
Conducer the following code

Steps to reproduce:

import ballerinax/copybook;
import ballerina/io;

public function main() returns error? {
    copybook:Convertor converter = check new ("copybook.cpy");
    map<json> jsonInput = {"Decimal": 10};
    string copybook = check converter.toCopybook(jsonInput);
    io:println(copybook);
}

Following is the copybook definition

01 Decimal    PIC 9(2).99.

expected:
10.00

getting:

error: {ballerina/lang.string}StringOperationError {"message":"string index out of range. Length:'1' requested: '0' to '2'"}

Affected Versions:

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/copybook Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
1 participant