I would like to parse json such as this example, where there is a client section, then a section for transactions:
{
"CLIENT": {
"CLIENTID": 1047,
"CLIENTNAME": "Alice"
},
"TRANSACTIONS": [
{"DATE": "2026-10-01","AMOUNT": 100.50},
{"DATE": "2026-10-02","AMOUNT": -20.00}
]
}
So I have a matching working storage area like this:
01 CLIENT-DATA.
03 CLIENT.
05 CLIENTID PIC 9(9).
05 CLIENTNAME PIC X(50).
03 TRANSACTIONS OCCURS 2 TIMES.
05 TRANDATE PIC X(10).
05 TRANAMOUNT PIC 9(5).
Then, after converting to UTF8, I'm trying to parse into CLIENT-DATA like so:
JSON PARSE JSON-UTF8 INTO CLIENT-DATA
NAME OF TRANDATE IS "DATE"
TRANAMOUNT IS "AMOUNT"
But when I run the program, I get lots of errors like this:
IGZ0322I During execution of the JSON PARSE statement on line 37 of program JP_EX, no data item matched JSON name "CLIENT" at offset 3.
IGZ0322I During execution of the JSON PARSE statement on line 37 of program JP_EX, no data item matched JSON name "CLIENTID" at offset 14.
The only way I have found to get this working is to split the json into two separate blocks, then do two separate JSON PARSES, and this works but I really want to be able to parse the whole json without having to do that. I have attached the full code as an attachment.
Can anyone advise please?
------------------------------
Steve Newbery
------------------------------