JSON GENERATE and JSON PARSE
Two COBOL statements in newer Enterprise COBOL that turn a data structure into JSON text, and JSON text back into a data structure.
Also written JSON GENERATE, JSON PARSE, COBOL JSON, XML GENERATE, XML PARSE
Web and mobile systems usually exchange data as JSON. Newer versions of Enterprise COBOL can produce and read JSON directly.
JSON GENERATE takes a group item, such as a customer record, and produces JSON text from it. Each field becomes a name and value, with the names taken from the COBOL field names, and nested groups become nested objects. Options let you choose different names, leave out certain fields, and count how many characters were produced.
JSON PARSE does the reverse. It reads JSON text and fills in the fields of a group item that matches its structure. Errors, such as a value that does not fit its field, are reported so the program can handle them.
COBOL has had XML GENERATE and XML PARSE for longer, for the same purposes with XML.
These statements let existing COBOL programs take part in modern interfaces without separate conversion code. They are often used together with z/OS Connect, CICS web services or MQ, when a COBOL program needs to send or receive messages that other systems expect in JSON.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- Enterprise COBOLIBM's COBOL compiler for z/OS, the version almost every mainframe COBOL program is compiled with today.
- WORKING-STORAGEThe section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.
- z/OS ConnectIBM software that makes mainframe programs and data available as REST APIs, so web and mobile applications can use them.
- Channels and containersThe newer way for CICS programs to pass data: named containers of any size, grouped into a channel.