Hi,
I have a query regarding JSON PARSE statement; and corresponding COBOL declaration.
For the following JSON the corresponding COBOL declaration would be
JSON
client-data":{
"account-num":123456789012,
"balance":-125.53,
"billing-info":{
"name-first":"John",
"name-last":"Smith",
"addr-street":"12345 First Avenue",
"addr-city":"New York",
"addr-region":"New York",
"addr-code":"10203"
}
}
COBOL Declaration.
01 client-data.
03 account-num pic 999,999,999,999.
03 balance pic $$$9.99CR.
03 billing-info.
05 name-first pic X(20).
05 name-last pic X(20).
05 addr-street pic X(20).
05 addr-city pic X(20).
05 addr-region pic X(20).
05 addr-code pic X(10).
What would be the corresponding COBOL declaration if the JSON started with a "[" i,e. if the JSON looks like
client-data":[
"account-num":123456789012,
"balance":-125.53,
"billing-info":{
"name-first":"John",
"name-last":"Smith",
"addr-street":"12345 First Avenue",
"addr-city":"New York",
"addr-region":"New York",
"addr-code":"10203"
}
]
Thank you
Anand B.
01 JSONP-REC.
05 PIC U(58) VALUE
'{"COUNTRYCODE": "FR","FORMSTATUSCHANGEREASON": "",'.
05 PIC U(58) VALUE
'"ID-N": "XXX-XX-XXXX",'.
05 PIC U(58) VALUE
'"SIGNATUREDATE": "2018-01-01","STATUS-C": "C",'.
05 PIC U(58) VALUE
'"TYPE-C": "AB"}'.
05 PIC U(58) VALUE SPACE.
05 PIC U(768) VALUE SPACE.
01 OUTPUT-REC.
05 RESP-REC OCCURS 01 .
10 COUNTRYCODE PIC X(02).
10 FORMSTATUSCHANGEREASON PIC X(40).
10 ID-N PIC X(12).
10 SIGNATUREDATE PIC X(10).
10 STATUS-C PIC X(01).
10 TYPE-C PIC X(02).
JSON PARSE JSONP-REC
INTO RESP-REC (01) WITH DETAIL
NAME RESP-REC IS OMITTED.
DISPLAY 'COUNTRYCODE '
COUNTRYCODE(01) .
DISPLAY 'FORMSTATUSCHANGEREASON '
FORMSTATUSCHANGEREASON(01) .
DISPLAY 'ID-N '
ID-N(01) .
DISPLAY 'SIGNATUREDATE '
SIGNATUREDATE(01) .
DISPLAY 'STATUS-C '
STATUS-C(01) .
DISPLAY 'TYPE-C '
TYPE-C(01) .