IDENTIFICATION DIVISION. PROGRAM-ID. P37NBU1. ****************************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. ****************************************************************** DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 MY-RECORD-1. 05 NUM-FIELD-1 PIC S9(3) SIGN LEADING SEPARATE. 01 MY-RECORD-2. 05 NUM-FIELD-2 PIC -9(3). 01 JSON-WORK-FIELDS. 05 JSON-LEN PIC 9(4) COMP-5. 05 JSON-UTF8 PIC X(100). 05 JSON-EBCDIC PIC X(100). ****************************************************************** PROCEDURE DIVISION. PERFORM EXAMPLE-1 PERFORM EXAMPLE-2 STOP RUN. EXAMPLE-1 SECTION. * ------------------------------------------------------------- DISPLAY SPACE DISPLAY 'Example 1: PIC S9(3) SIGN LEADING SEPARATE' DISPLAY '==========================================' DISPLAY SPACE * ------------------------------------------------------------- MOVE -123 TO NUM-FIELD-1. DISPLAY ' Input : ' MY-RECORD-1 * ------------------------------------------------------------- INITIALIZE JSON-WORK-FIELDS JSON GENERATE JSON-UTF8 FROM MY-RECORD-1 COUNT IN JSON-LEN ON EXCEPTION DISPLAY "JsonGenerateException Example-1" END-JSON MOVE FUNCTION DISPLAY-OF( FUNCTION NATIONAL-OF( JSON-UTF8 (1 : JSON-LEN), 1208 ) ) TO JSON-EBCDIC DISPLAY ' Json : ' JSON-EBCDIC * ------------------------------------------------------------- INITIALIZE MY-RECORD-1 JSON PARSE JSON-UTF8 (1 : JSON-LEN) INTO MY-RECORD-1 WITH DETAIL ON EXCEPTION DISPLAY "JsonParseException Example-1" END-JSON DISPLAY ' Output: ' MY-RECORD-1 EXIT. EXAMPLE-2 SECTION. * ------------------------------------------------------------- DISPLAY SPACE DISPLAY 'Example 2: PIC -9(3)' DISPLAY '====================' DISPLAY SPACE * ------------------------------------------------------------- MOVE -123 TO NUM-FIELD-2. DISPLAY ' Input : ' MY-RECORD-2 * ------------------------------------------------------------- INITIALIZE JSON-WORK-FIELDS JSON GENERATE JSON-UTF8 FROM MY-RECORD-2 COUNT IN JSON-LEN ON EXCEPTION DISPLAY "JsonGenerateException Example-2" END-JSON MOVE FUNCTION DISPLAY-OF( FUNCTION NATIONAL-OF( JSON-UTF8 (1 : JSON-LEN), 1208 ) ) TO JSON-EBCDIC DISPLAY ' Json : ' JSON-EBCDIC * ------------------------------------------------------------- INITIALIZE MY-RECORD-2 JSON PARSE JSON-UTF8 (1 : JSON-LEN) INTO MY-RECORD-2 WITH DETAIL ON EXCEPTION DISPLAY "JsonParseException Example-2" END-JSON DISPLAY ' Output: ' MY-RECORD-2 EXIT.