DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stop Poisoning Your Models: How I Built a CV Dataset Quality Toolkit I Can Reuse Forever
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • The Update Problem REST Doesn't Solve
  • Designing a Production-Grade Multi-Agent LLM Architecture for Structured Data Extraction

Trending

  • Mocking Kafka for Local Spring Development
  • Why AI-Generated Code Breaks Your Testing Assumptions
  • Retesting Best Practices for Agile Teams: A Quick Guide to Bug Fix Verification
  • Run Gemma 4 on Your Laptop: A Hands-On Guide to Google's Latest Open Multimodal LLM
  1. DZone
  2. Coding
  3. Languages
  4. COBOL Copybook Transformation to JSON in Mule4

COBOL Copybook Transformation to JSON in Mule4

Learn more about COBOL copybook and how to transform to JSON in Mule4.

By 
Priyabrata Dash user avatar
Priyabrata Dash
·
May. 10, 22 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
5.9K Views

Join the DZone community and get the full member experience.

Join For Free

What Is COBOL Copybook?

A COBOL copybook is a type of flat file that describes the layout of records and fields present in the file.

Example of Copybook data:

Copybook dataLet’s say the above example is a representation of Employee data which consists of Employee Number, name, phone number, and dept which is based on the below copybook definition:

 Employee data

Steps To Convert the Copybook Into JSON

Step 1:

As part of the first step, we need to generate a flat-file schema definition i.e.  .ffd file from the above-provided copybook (.cpy file) using the Transform Message component. 

Import a COBOL definition .cpy file into the Transform Message component by selecting the  Set Meta-Data Type in the Transform message Input section. 

Set Meta-Data Type

Once the import of the .cpy file is correctly done then, the Transform component will convert this .cpy file and generate the flat file schema definition, and will store it inside the src/main/resources/schema folder of your Mule project

schema

The generated flat-file schema file looks like the below:

flat-file schema

Step 2:

Drag and drop the Set Payload component from Mule Palette to specify MIME Type and the schema path of the incoming payload. MIME-type should be “application/flatfile”. Under schemaPath specify the above-generated .ffd file path.

Set payload

Step 3:

Drag and drop the Transform Message component after the Set Payload for data conversion.

Transform Message component

The final mule application now looks like this:

cobol to json flow

Test Using Postman

Request:

Request

Response:

Response

COBOL JSON

Opinions expressed by DZone contributors are their own.

Related

  • Stop Poisoning Your Models: How I Built a CV Dataset Quality Toolkit I Can Reuse Forever
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • The Update Problem REST Doesn't Solve
  • Designing a Production-Grade Multi-Agent LLM Architecture for Structured Data Extraction

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook