copybook
Module copybook
![](https://bcentral-dev-packageicons.azureedge.net/images/ballerinax_copybook_0.1.0.png)
ballerinax/copybook Ballerina library
Overview
This module provides APIs to convert Cobol Copybook data to JSON or Ballerina records and vice versa.
Classes![](/images/permalink.svg)
copybook: Convertor![](/images/permalink.svg)
This class represents a copybook convertor that facilitates the conversion of ASCII data to and from JSON data.
Constructor![](/images/permalink.svg)
Initializes the convertor with a schema.
init (string schemaFilePath)
- schemaFilePath string - The path of the copybook file
toJson![](/images/permalink.svg)
Converts the given ASCII string to a JSON value.
Parameters
- copybookData string - The ASCII string that needs to be converted to JSON
- targetRecordName string? (default ()) - The name of the copybook record definition in the copybook. This parameter must be a string if the provided schema file contains more than one copybook record type definition
Return Type
toCopybook![](/images/permalink.svg)
Converts the provided record or map
Parameters
- input record {} - The JSON value that needs to be converted as copybook data
- targetRecordName string? (default ()) - The name of the copybook record definition in the copybook. This parameter must be a string if the provided schema file contains more than one copybook record type definition
Return Type
fromCopybook![](/images/permalink.svg)
function fromCopybook(string copybookData, string? targetRecordName, typedesc<record {}> t) returns t|Error
Converts the given ASCII string to a Ballerina record.
Parameters
- copybookData string - The ASCII string that needs to be converted to a record value
- targetRecordName string? (default ()) - The name of the copybook record definition in the copybook. This parameter must be a string if the provided schema file contains more than one copybook record type definition
- t typedesc<record {}> (default <>) - The type of the target record type
Return Type
- t|Error - A record value on success, a
copybook:Error
in case of coercion errors
Errors![](/images/permalink.svg)
copybook: Error![](/images/permalink.svg)
Represents copybook module related errors.
Import
import ballerinax/copybook;
Metadata
Released date: 8 months ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: java17
Ballerina version: 2201.8.0-20230830-220400-8a7556d8
GraalVM compatible: Yes
Pull count
Total: 4
Current verison: 1
Weekly downloads
Keywords
copybook
serdes
cobol
mainframe
Contributors