Latest COBOL features

A few of my favorite COBOL features are JSON GENERATE and JSON PARSE. If you want more information https://www.youtube.com/watch?v=N_Zsd1W8hWc

1 Like

JSON support is a nice feature if your COBOL systems need to communicate with RESTFUL services in the cloud (or in your own local environment) or if the COBOL program needs to process (or produce) JSON formatted data.

Historically this is not a feature that was available in most COBOL systems. For such systems it is possible to create a JSON parser using COBOL code so that COBOL programs can utilize JSON structures if necessary. This can help to enhance the capability of some of those old workhorse COBOL programs that some organizations rely upon.

I found the FUNCTION HEX-OF(alphanumeric-item) to be valuable last week. Saved a lot of lines of coding, as well as being easier to read.

There is also a BIT-OF function too, if you want to get the bit-string of the alpha.

This is new with Enterprise COBOL V6.3

1 Like

Been coding COBOL for 40 plus years Iā€™ve never heard of JSON. What is that?

Hi Richard ā€“

JSON is a simple text-based data exchange format popular with Python and JavaScript programmers, and ported to tons of other languages as well.

though Iā€™d skip the history section, itā€™s more confusing than enlightening.

Bob

Iā€™m a huge fan of our environment (Veryant/isCOBOL) and its ability to create API-accessible programs. We can use certain compiler settings to generate RESTful COBOL endpoints and define the structure of the JSON object for the HTTP requests using syntax on a linkage section of the program. Weā€™ve built an entire RESTful COBOL application with a ReactJS frontend because of this functionality.

Hi,
Thanks for the new view. How do you invoke APIs in COBOL? Are you using cloud?
Curious to know.
Regards
Lakshmisudha

Our runtime environment and version of COBOL, isCOBOL from Veryant, has built-in functionality that allows you to create a ā€œbridgeā€ program based on the linkage section. That bridge uses OOP to connect to HTTP requests sent via (in our case) Tomcat. The bridge then unpacks the expected JSON or XML object and properly loads the data into the corresponding linkage section group item. That data is then passed in to the main program. Itā€™s super easy and has been game changing for us.

1 Like

Thanks. That helps. :grinning:

Could you please share sample example how to use JSON to communicate to COBOL ?

Please have a look at IBMā€™s sample:

Noticed that this is a wildly confusing thread. Short answer is Javascript Object Notation. A viewer friendly representation of information very unlike XML. Biggest problem is the Networking components arenā€™t mentioned. Yes Tomcat, (Geronimo <=> Websphere, JBossā€¦et al ) and Apache HTTP work on z/OS. However you have to create ā€œholesā€ (good luck with that ) which punch their way through your firewalls in order to get out over the open internet and talk turkey with the various API services that use REST and SOAP (XML). Use Node on z/OS or z/Linux if you can. Not sure if IBM is still plastering that Go Domino web server on their big Iron machines these days. It was a horrible beast. So itā€™s not as simple as do this and youā€™ll be fine.
BTW : most Cisco installations kill certain routing protocols on their networks as a security measureā€¦ donā€™t believe the hype about itā€™s necessarily straight forward. You may always be blocked from the internet.

Hi Paul,
There are a lot more examples the way round (parse) than the generate one.
May I ask an updated link, because the present one fails.
Thank you
Stay safe
Georges KOPP

See JSON. It is a subset of the JavaScript Programming Language Standard. It is the portion of JavaScript that represents data but without any logic. Most languages support, or have a library, that converts data from the languageā€™s representation and to the languageā€™s representation. Python is not COBOL but for what it is worth, Python has many libraries to do it, most of which are cumbersome. Typically the hard part of using JSON is figuring out the definition of the data for your language, such as COBOL. For most languages and for most samples of data there are online tools that can analyze sample JSON data and generate the source code for the data.