|
From the above I can see that api_product_list_json is the start of anarray and there is one element (element 0)
From: "Jon Paris" <jon.paris@xxxxxxxxxxxxxx>there is
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-
l@xxxxxxxxxxxxxxxxxx>
Date: 12/01/2019 03:45 AM
Subject: Re: DATA-INTO Json failing
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>
Answer turns out to be pretty easy - assuming of course that your
sample is accurate.
This version of your code works:
Ctl-Opt DFTACTGRP(*NO);
dcl-ds aaaaa qualified;
refresh_token_expires_in varchar(10);
num_api_product_list int(5) ;
api_product_list varchar(50) dim(5);
num_api_product_list_json int(5) ;
api_product_list_json varchar(50) dim(5);
organization_name varchar(50);
developer_email varchar(50);
token_type varchar(50);
issued_at varchar(20);
client_id varchar(50);
access_token varchar(50);
application_name varchar(50);
scope varchar(50);
expires_in varchar(10);
refresh_count varchar(10);
status varchar(20);
end-ds;
Dcl-s myjson varchar(5000);
myjson = '{ +
"refresh_token_expires_in" : "0", +
"api_product_list" : "[P2P Rideshare API Product]", +
"api_product_list_json" : [ "P2P Rideshare API Product" ], +
"organization_name" : "onegov", +
"developer.email" : "sam@xxxxxxxxx", +
"token_type" : "BearerToken", +
"issued_at" : "1547071634302", +
"client_id" : "WmTFrOi8ZXBa0RBn6Tx2vYd3dnkOgtjj", +
"access_token" : "ePpNwfSoCUosyHpqQJlcK3zAjHeG", +
"application_name" : "2d8ee44d-5621-459a-8e44-7946c8d319dd", +
"scope" : "", +
"expires_in" : "43199", +
"refresh_count" : "0", +
"status" : "approved" +
}';
data-into aaaaa %data( myjson :
'case=convert countprefix=num_ ')
%Parser( 'YAJL/YAJLINTO' );
*inlr = *on;
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Jan 10, 2019, at 5:14 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:
Thanks Barbara,
I have tried quite a few combinations and still receive the error
indicating the data structure is not correct
PTF SI68421 is installed on my system.
This is the line in the json that is causing the problems;
"api_product_list_json" : [ "P2P Rideshare API Product" ],
To me this is saying it is an array because of the [ brackets but
noonly one name in the array with no value ? Or is that the value with
operation,name ?
The error confirms that is the line causing the issue;
Message ID . . . . . . : RNX0356
Message . . . . : The document for the DATA-INTO operation does not
match
the RPG variable; reason code 6.
Cause . . . . . : While parsing a document for the DATA-INTO
exactthe
parser found that the document does not correspond to RPG variable
"aaaaa"
and the options do not allow for this. The reason code is 6. The
indicatessubfield for which the error was detected is
"aaaaa.api_product_list_json(1)". The options are "case=convert
countprefix=num_". The document name is *N; *N indicates that the
document
is not an external file. The parser is 'YAJL72/YAJLINTO'. *N
?that
the parser is a procedure pointer.
I have pasted the entire program below which should compile and run.
How should I be defining the data structure to parse this json string
H DFTACTGRP(*NO)
dcl-ds aaaaa qualified;
refresh_token_expires_in varchar(10);
api_product_list varchar(50) ;
num_api_product_list_json int(10) ;
dcl-ds api_product_list_json dim(5);
api_product_list_json varchar(50) ;
// P2P_Rideshare_API_Product varchar(50) ;
end-ds ;
organization_name varchar(50);
developer_email varchar(50);
token_type varchar(50);
issued_at varchar(20);
client_id varchar(50);
access_token varchar(50);
application_name varchar(50);
scope varchar(50);
expires_in varchar(10);
refresh_count varchar(10);
status varchar(20);
end-ds;
D myjson s 5000a varying
/free
myjson = '{ +
"refresh_token_expires_in" : "0", +
"api_product_list" : "[P2P Rideshare API Product]", +
"api_product_list_json" : [ "P2P Rideshare API Product" ], +
"organization_name" : "onegov", +
"developer.email" : "sam@xxxxxxxxx", +
"token_type" : "BearerToken", +
"issued_at" : "1547071634302", +
"client_id" : "WmTFrOi8ZXBa0RBn6Tx2vYd3dnkOgtjj", +
"access_token" : "ePpNwfSoCUosyHpqQJlcK3zAjHeG", +
"application_name" : "2d8ee44d-5621-459a-8e44-7946c8d319dd", +
structure"scope" : "", +
"expires_in" : "43199", +
"refresh_count" : "0", +
"status" : "approved" +
}';
data-into aaaaa %data( myjson :
'case=convert countprefix=num_')
%Parser( 'YAJLINTO' );
*inlr = *on;
/end-free
/free
Don Brown
"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 10/01/2019
10:33:09 PM:
From: "Barbara Morris" <bmorris@xxxxxxxxxx>
To: rpg400-l@xxxxxxxxxxxx
Date: 10/01/2019 10:33 PM
Subject: Re: DATA-INTO Json failing
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>
On 2019-01-10 1:34 AM, Don Brown wrote:
I am hoping someone can advise how I need to create the data
noof
DATA-INTO with this json string.
...
But the following line api_product_list_json is an array but it has
Rideshareelements ?
...
{
"refresh_token_expires_in" : "0",
"api_product_list" : "[P2P Rideshare API Product]",
"api_product_list_json" : [ "P2P Rideshare API Product" ],
...
data-into aaaaa %data( myjson : 'case=convert')
%Parser( 'YAJL72/YAJLINTO' );
This fails to load the "api_product_list_json" : [ "P2P
hasAPI
Product" ],
...
You said that api_product_list_json has no elements, but your json
orone element for the array.
Since you only have one element, and you have DIM(5) in the data
structure, you would need to either specify option allowmissing=yes,
structure,better, add a subfield num_api_product_list_json to your data
bug
and specify option countprefix=num.
But if you do actually have an empty array in the json, there was a
affiliatein DATA-INTO where it didn't handle an empty array. You need 7.2 PTFquestions.
SI68422 or 7.3 PTF SI68421 to fix that.
--
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@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
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
Help support midrange.com by shopping at amazon.com with our
______________________________________________________________________link:
https://amazon.midrange.com
______________________________________________________________________This email has been scanned by the Symantec Email Security.cloudservice.
For more information please visit http://www.symanteccloud.com
service.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
questions.For more information please visit http://www.symanteccloud.com(RPG400-L) mailing list
______________________________________________________________________
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
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.affiliate link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
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
link:
Help support midrange.com by shopping at amazon.com with our affiliate
https://amazon.midrange.comservice.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.