Thanks Robert.
We use Enterprise COBOL 6.3 and the single response worked.
countryCode:FR
formStatusChangeReason:
id:XXX-XX-XXXX
signatureDate:2018-01-01
status:
type:AB
Was trying for array-->
01 inrec.
05 pic u(50)
VALUE '{"countryCode": "FR","formStatusChangeReason": "",'.
05 pic u(30)
value '"id-n": "XXX-XX-XXXX",'.
05 pic u(30)
value '"signatureDate": "2018-01-01",'.
05 pic u(30)
value '"status-c": " ","type-c": "AB"}'.
05 pic u(50)
VALUE '{"countryCode": "NJ","formStatusChangeReason": "",'.
05 pic u(30)
value '"id-n": "IXX-XX-XXXX",'.
05 pic u(30)
value '"signatureDate": "2022-01-01",'.
05 pic u(30)
value '"status-c": " ","type-c": "DA"}'.
05 pic u(736).
01 resp-rec.
02 RESP-ARRAY OCCURS 02 TIMES.
05 countryCode PIC X(02).
05 formStatusChangeReason PIC X(40).
05 id-n PIC X(12).
05 signatureDate PIC X(10).
05 status-c PIC X(01).
05 type-c PIC X(02).
JSON PARSE inrec INTO resp-rec WITH DETAIL
NAME resp-rec IS OMITTED.
display 'resp-rec written:'resp-rec.
display 'countryCode:' countryCode(1).
display 'countryCode:' countryCode(2).
display 'formStatusChangeReason:'formStatusChangeReason(1).
display 'formStatusChangeReason:'formStatusChangeReason(2).
display 'id:' id-n(1)
display 'id:' id-n(2).
display 'signatureDate:' signatureDate(1).
display 'signatureDate:' signatureDate(2).
display 'status:' status-c(1).
display 'status:' status-c(1).
display 'type:' type-c(1).
display 'type:' type-c(2).
during execution got below
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "countryCode" at offset 1.
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "formStatusChangeReason" at offset 21.
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "id-n" at offset 200.
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "signatureDate" at offset 320.
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "status-c" at offset 440.
IGZ0322I During execution of the JSON PARSE statement on line 394 of program JPARPGM, no data item matched JSON name "type-c" at offset 456.
countryCode:
countryCode:
formStatusChangeReason:
formStatusChangeReason:
id:
id:
signatureDate:
signatureDate:
status:
status:
type:
type:
JSON Parse Command for a JSON that starts with [
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: JSON Parse Command for a JSON that starts with [
The Language Reference manual explains your results:
The last point is where you got tripped up -- RESP-ARRAY is a group data item so everything under it will be ignored.The following data items that are specified by identifier-2 are ignored by
the JSON PARSE statement:
v Any subordinate unnamed elementary data items or elementary FILLER
data items
v Any slack bytes inserted for SYNCHRONIZED items
v Any data item subordinate to identifier-2 that is defined with the
REDEFINES clause or that is subordinate to such a redefining item
v Any data item subordinate to identifier-2 that is defined with the
RENAMES clause
v Any group data item all of whose subordinate data items are ignored
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 4015
-
by Leixner
View the latest post
Thu Sep 15, 2022 3:33 am
-
- 1
- 2970
-
by oliver07
View the latest post
Sat Oct 30, 2021 2:32 pm
-
- 5
- 2445
-
by willy jensen
View the latest post
Tue Oct 12, 2021 2:02 pm
-
- 6
- 2465
-
by MFDEV
View the latest post
Fri Sep 11, 2020 9:04 am
-
- 4
- 1393
-
by futohomok
View the latest post
Mon Oct 16, 2023 9:01 pm