One day you, the developer, receives a JSON Schema from, for example, a public institution. It contains a spec of the data they will provide soon. In JSON of course. Your company ask you to create a JSON Parser in Cobol that can handle read of data and update in one or more databases. Fine, just and example, but actually taken from real life. Already you have a JSON Parser in Cobol on mainframe. At least since version 6.2. It requires a Cobol Copybook to “parse the data into” – using selection criterias or indicators…. or whatever you need…!

We decided to create our own JsonSchemaToCobol copybook conversion tool, that, when it read and converts large-large JSON Schemas, saves us A LOT of time in creating Cobol Copybooks for JSON. For the furure, when Schemas as changed it will be very valuable to us.

This is how we did it. The key features are:

State Management (useState)

  • Stores JSON Schema input, COBOL output, and toggle for including comments.

Reference Handling (resolveRef)

  • Resolves $ref references in JSON Schema for nested objects.

COBOL Type Mapping (getCobolType)

  • Converts JSON Schema types to COBOL data formats.

Recursive Schema Parsing (generateCobolLayout)

  • Generates COBOL structure from JSON Schema, handling objects and arrays.

Main Conversion Logic (convertToCobol)

  • Parses JSON Schema and generates COBOL layout.

User Interaction

  • Buttons for converting, clearing, and copying output.
  • Textareas for input and output with proper styling.

Clipboard Support (selectAndCopy)

  • Allows easy copying of generated COBOL code.

Higher-Order Component (withRouter)

Wraps the component for potential navigation support.

It does more, but these are (perhaps) the key features.

Finally: If you want a demo do not hesitate in contacting us. We are sure you can create one on your own. Also we know excellent people that are happy to help you on consultancy basis. They can bring our code to you and you can have the code customized if needed. After that the code is yours.

By Admin

Leave a Reply

Your email address will not be published. Required fields are marked *