× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks to all who replied.

Greg: Thanks for the tip, I have installed the json plugin for Firefox. I
feel this is going to get good use.

Greg: I also opened the json string in Firefox. I am not sure how to
interpret the results. (At least the results are consistent between
Notepad++ and Firefox)

Jon: Thank you for your response, your solution works but I must admit to
being confused as per my comment (To me this is saying it is an array
because of the [ brackets but there is only one name in the array with no
value ? Or is that the value with no name ?) Let me provide more detail...

Here is a snippet of the json where i am confused; (I hope my formatting
does not get screwed up when this is posted!)
On the left is the JSON and on the right (format gods permitting) is the
corresponding data structure.

{ dcl-ds aaaaa
qualified;
(1) "refresh_token_expires_in": "0",
refresh_token_expires_in varchar(10);
(2)
num_api_product_list int(5) ;
(3) "api_product_list": "[P2P Rideshare API Product]",
api_product_list varchar(50) dim(5);
(4)
num_api_product_list_json int(5) ;
(5) "api_product_list_json": [
api_product_list_json varchar(50) dim(5);
(6) "P2P Rideshare API Product"
(7) ],
(8) "organization_name": "onegov",
organization_name varchar(50);
} end-ds;

Line (1) is name and value
Line (2) provides the count for the following array (Which I am not
understanding as to why this is an array??)
Line (3) this is confusing as to me this should just be name and value but
the solution was to interpret this as an array. Why ? The brackets [ ]
are inside double quotes. Does this mean that if you have a left [ and
right ] bracket within a value that it will be interpreted as an array ?
Line (4) provides the count for the following array
Lines (5, 6 and 7) is an array with one element
Line (8) is name and value

When I view this in Notepad++ (thanks Greg) with the JSON viewer or
Firefox it shows as follows;

JSON
refresh_token_expires_in "0"
api_product_list "[P2P Rideshare API Product]"
api_product_list_json
0 "P2P Rideshare API Product"
organization_name "onegov"
...

From the above I can see that api_product_list_json is the start of an
array and there is one element (element 0)

But I can see nothing that indicates the api_product_list "[P2P
Rideshare API Product]" is an array but adding a count to the data
structure makes this work???
If I add brackets [ ] outside EG api_product_list ["[P2P Rideshare
API Product]"] this is then interpreted as an array in Notepad++ as I
expected.

Is this just valid but poor JSON coding by the site providing this JSON
response ?

Jon: Did you just look at this and go; there's the error, that's an array
or how did you identify line (3) needed a count ?

Thank you


Don Brown

"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 12/01/2019
03:45:25 AM:

From: "Jon Paris" <jon.paris@xxxxxxxxxxxxxx>
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
there is
only one name in the array with no value ? Or is that the value with
no
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
operation,
the
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
exact
subfield 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
indicates
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", +

"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
structure
of
DATA-INTO with this json string.
...
But the following line api_product_list_json is an array but it has
no
elements ?
...
{
"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
Rideshare
API
Product" ],
...

You said that api_product_list_json has no elements, but your json
has
one 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,
or
better, add a subfield num_api_product_list_json to your data
structure,

and specify option countprefix=num.

But if you do actually have an empty array in the json, there was a
bug
in DATA-INTO where it didn't handle an empty array. You need 7.2 PTF
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
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link:
https://amazon.midrange.com


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
service.
For more information please visit http://www.symanteccloud.com

______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--
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
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate link: https://amazon.midrange.com

--
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
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:
https://amazon.midrange.com

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.