Hi , can you help me please
it doesn't work
dcl-ds allresponse qualified;
dcl-ds CodeAct dim(3);
codeActiviteFm varchar(100);
isAs400FiniPousserDansFm Ind;
isOverlogFiniPousserDansFm Ind;
isPrevisionsPretesPourIntegration varchar(200);
dcl-ds traceabilites dim(3);
propriete varchar(100);
horodatage varchar(100);
modificateur varchar(100);
end-ds;
end-ds;
data-into allresponse %data(Filename:
'doc=file case=any')
%Parser('YAJLLIB72/YAJLINTO');
My json: [{"codeActiviteFm":"01","isAs400FiniPousserDansFm":true,"isOverlogFiniPousserDansFm":true,"isPrevisionsPretesPourIntegration":false,"modificateur":null,"traceabilites":[{"propriete":"IsPrevisionsPretesPourIntegration","horodatage":"2022-01-13T07:31:05","modificateur":"OVL "},{"propriete":"IsOverlogFiniPousserDansFm","horodatage":"2022-01-13T00:24:25","modificateur":"OVL "}]},{"codeActiviteFm":"02","isAs400FiniPousserDansFm":true,"isOverlogFiniPousserDansFm":true,"isPrevisionsPretesPourIntegration":false,"modificateur":null,"traceabilites":[{"propriete":"IsPrevisionsPretesPourIntegration","horodatage":"2022-01-13T07:51:01","modificateur":"OVL "},{"propriete":"IsOverlogFiniPousserDansFm","horodatage":"2022-01-13T00:52:30","modificateur":"OVL "}]},{"codeActiviteFm":"03","isAs400FiniPousserDansFm":true,"isOverlogFiniPousserDansFm":true,"isPrevisionsPretesPourIntegration":false,"modificateur":null,"traceabilites":[{"propriete":"IsPrevisionsPretesPourIntegration","horodatage":"2022-01-13T08:08:35","modificateur":"OVL "},{"propriete":"IsOverlogFiniPousserDansFm","horodatage":"2022-01-13T00:54:30","modificateur":"OVL "}]}]
DATA-INTO
Re: DATA-INTO
There are a few things wrong here.
First the json doc starts with an array so you should really just be targetting an array - so I just removed the outer allrespnse DS.
You'll need to know how many elements there are so you need to add the PSDS count field definition.
Also ideally you should add a count to the nested traceabilities array so you know how many elements there are there.
I also had to add allowextra=yes to handle the fact that there are elemets in the json that you had not accommodated in the DS. So in the end it looked like this:
This appears to work just fine.
First the json doc starts with an array so you should really just be targetting an array - so I just removed the outer allrespnse DS.
You'll need to know how many elements there are so you need to add the PSDS count field definition.
Also ideally you should add a count to the nested traceabilities array so you know how many elements there are there.
I also had to add allowextra=yes to handle the fact that there are elemets in the json that you had not accommodated in the DS. So in the end it looked like this:
Code: Select all
dcl-ds PSDS psds;
numElements int(20) pos(372);
end-ds;
dcl-ds CodeAct Qualified Dim(3);
codeActiviteFm varchar(100);
isAs400FiniPousserDansFm Ind;
isOverlogFiniPousserDansFm Ind;
isPrevisionsPretesPourIntegration varchar(200);
num_traceabilites int(5); /// Count for nested array
dcl-ds traceabilites dim(3);
propriete varchar(100);
horodatage varchar(100);
modificateur varchar(100);
end-ds;
end-ds;
// I coded the json in the source so no file reference
data-into CodeAct %Data(JsonData : 'case=any allowextra=yes countprefix=num_')
%Parser( 'YAJL/YAJLINTO' );
Dsply (%char( numElements) + ' elements processed');