copybook
ballerinax/copybook Ballerina library
Overview
This module provides APIs to convert Cobol Copybook data to JSON or Ballerina records and vice versa.
Classes
copybook: Converter
This class represents a copybook converter that facilitates the conversion of ASCII data to and from JSON data.
Constructor
Initializes the converter with a schema.
init (string schemaFilePath)
- schemaFilePath string - The path of the copybook file
toBytes
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
- encoding Encoding (default ASCII) - The encoding of the output bytes array. Default is ASCII
Return Type
- byte[]|Error - The converted byte array. In case of an error, a
copybook:Error
is is returned
fromBytes
function fromBytes(byte[] bytes, string? targetRecordName, Encoding encoding) returns map<json>|Error
Converts the given copybook bytes to a Ballerina record.
Parameters
- bytes byte[] - Bytes array 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
- encoding Encoding (default ASCII) - The encoding of the input bytes array. Default is ASCII
Enums
copybook: Encoding
Represents the encoding types used for the input or output byte arrays.
Members
Errors
copybook: Error
Represents copybook module related errors.
Import
import ballerinax/copybook;
Metadata
Released date: about 2 months ago
Version: 1.0.2
License: Apache-2.0
Compatibility
Platform: java17
Ballerina version: 2201.8.0
GraalVM compatible: Yes
Pull count
Total: 72
Current verison: 3
Weekly downloads
Keywords
copybook
serdes
cobol
mainframe
Contributors
Dependencies