Thanks for the help on change the code.
Thanks
John Slanina
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxx> On Behalf Of Barbara Morris
Sent: Monday, April 23, 2018 6:19 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: How to use data-into with json that don't have an object name ?
On 2018-04-23 3:47 PM, Slanina, John wrote:
what happens if it like this
{
"AccountNumber":"31695801",
"Name":"JOHN"
Plus 20 other fields
}
The JSONPARSE program doesn't support JSON like that.
You could copy your JSONPARSE source to another source member, say JSONPARSE2, and edit it so that it always reports the start of a data structure for a '{' character and it always reports the end of a data structure for a '}' character. Then, when you have a JSON document like that, specify program JSONPARSE2 instead of JSONPARSE in %PARSER.
The places to change are:
1. Remove the IF and ENDIF (and the comment) here:
if parseCtrl.ctrlStk.top > 1;
// If top = 1, this is the initial curly brace to begin
// the JSON document. It does not match an RPG data structure
// So we only report the start of a structure if top > 1
QrnDiStartStruct(parseCtrl.handle);
endif;
2. Remove the IF and ENDIF (and the comment) here:
if parseCtrl.ctrlStk.top > 1;
// If top = 1, it matches the initial curly brace to begin
// the JSON document. It did not match an RPG data structure.
// So we only report the end of a structure if top > 1
QrnDiEndStruct(parseCtrl.handle);
endif;
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.