|
The devil is in the details and the RPG SQL precompiler....
Unlike many of the examples I'm not reading the JSON from a IFS document.
It's in a clob in a db2 table. So on the select, the clob is put into
this field:
Dcl-s wrkContent SQLTYPE(Clob:128000);
I've done this before but a few years ago. It gets generated as this:
//*DCL-S WRKCONTENT SQLTYPE(CLOB:128000);
DCL-DS WRKCONTENT;
//SQL
WRKCONTENT_LEN UNS(10);
//SQL
WRKCONTENT_DATA CHAR(128000) CCSID(*JOBRUNMIX);
//SQL
END-DS WRKCONTENT;
//SQL
So to access the JSON I should have been pointing the parser to
wrkContent_Data, not the array name.
This:
Data-Into txJSONDoc
%Data(wrkContent_DATA:'doc=string ' +
Not:
Data-Into txJSONDoc
%Data(wrkContent:'doc=string ' +
After fixing that I had all sorts of data mismatches and type errors.
There were numeric fields being passed in blanks. I found this to be
useful:
ADDENVVAR QIBM_RPG_DATA_INTO_TRACE_PARSER VALUE('*STDOUT')
See
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzasd/zzdatainto.htm
As it provided a nice running trace of what the parser was doing.
Thanks to all for their suggestions. I appreciate the quick responses.
Jack
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Nathan
Andelin
Sent: Tuesday, May 19, 2020 12:25 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: JSON Error Message
Although Jay may have been promoting a vendor product, I'd encourage the
list to download and review it, if for no other reason than to compare it
with IWS. People would benefit by understanding the interface.
IWS generates Java components and implements a Java runtime environment,
whereas Jay eschews that middle-ware layer and rather offers a generic
HTTP-CGI interface.
If you consider all the steps involved in IWS wizards just to configure
and deploy a web service; the process is tedious. The IWS admin and
programming guide is 170 pages filled with technical acronyms and
unfamiliar concepts.
Formatted input and output streams in IWS web services are super tightly
coupled with procedure interfaces in ILE programs or service programs,
while Jay's interface is whatever JSON input or JSON output you might want
to implement, which is super flexible.
In regard to flexible interfaces, you might deploy say "employee" web
services that support create, read, update, delete, list, fetch name
(formatted L, F M), fetch address, etc. all within a single program,
because all of the web services share the same database table (employees).
It's architecturally sound.
This is the type of interface that can give ODBC and JDBC a run for its
money.
You can parse/generate JSON with YAJL or SQL, or whatever.
It's not perfect. I can think of a lot of things I would change. But
people would benefit by getting a feel for how the interface works.
I've also been reviewing a couple of ILE RPG interfaces that bypass the
HTTP / CGI interface by implementing their own socket listeners. It's
interesting.
On Mon, May 18, 2020 at 5:54 PM Jay Vaughn <jeffersonvaughn@xxxxxxxxx>
wrote:
No biggie guys!posting.
Yes, lets keep the standard high on this forum.
Jay
On Mon, May 18, 2020 at 7:09 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:
For some reason Jay's response did not reach me. Due to to the
vagaries of gmail it may show up in a few hours.
So I will repeat here what I said to Nathan which is that I
apologize to Jay if indeed these were genuine code samples he was
now!
I took a shortcut and was wrong and I apologize.
On May 18, 2020, at 6:29 PM, Vernon Hambergwrote:
<vhamberg@xxxxxxxxxxxxxxx>
Hi Jay
Sharing source is fine - I suspect you already know the difference
Antonio","state":"TX","postalCode":"78256-1041","country":"US","county":null},"identification":"2001","identificationType":"SSN","contact":{"id":2,"mobilePhone":"","textOptIn":false,"homePhone":"","workPhone":"","email":"The main thing to avoid is to have product recommendations by thealways
vendor look like advice from the community of a solution to a
question. You
said something was a product of yours, so I wasn't too concerned -still, I
and others here treasure this resource and are glad David puts aJon
pretty high fence around it.
would that been better? Just saved time by posting the entire link.
Regards and thanks
Vern
On 5/18/2020 3:20 PM, Jay Vaughn wrote:
Sorry. Will try and remember nxt time.
If I just posted the program source code instead of the entire
link
try and remember next time.
Not sure how sharing source code is violation? But whatever. I
will
of the advertisements without the ability to <delete before read>.
Jay
On May 18, 2020, at 4:13 PM, midrangel@xxxxxxxxxxxxxxxxx wrote:
I've been waiting for David to say something, buy I agree, I'm
tired
--
Jim Oberholtzer
Agile Technology Architects
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf
Of
Paristhis
tagging things with <Vendor response> when you do this.Sent: Monday, May 18, 2020 3:05 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: JSON Error Message
Jay - maybe it is just me but I think it really is time you
started
wrote:
On May 18, 2020, at 4:00 PM, Jay Vaughn
<jeffersonvaughn@xxxxxxxxx>
Jack,
Sql json functions can look complex on the service but it can
easily be implemented using a programming approach I take in
something I've developed. Take a look at the sql json api
program at the end of
structures.document to see how you can easily build complicated json
Althoughdifferent related objects).The idea is to keep them strings and create multiple procedures
to keep appending to the json structure (ie. the
getJsonResponseObject_01 procedure can be replicated many times
for
wrote:
https://jeffersonvaughn.com/gallery/coreiRST%20Overview.pdf
Jay
On Mon, May 18, 2020 at 2:33 PM Jack Prucha
<Jack.Prucha@xxxxxxx>
Hello Jon,
I attended your RPG/DB2 seminars in the suburbs of Chicago.
hotel.I live far from there now I grew up a few miles away from the
{"id":1,"userId":10415785,"accountNumber":null,"dateOfBirth":"1999-08out ofIt was convenient to visit family and save the company some $
by having my sister pick me up at the airport.
Yes, I successfully validated with JSONLINT. Copied the results
the Run SQL Scripts result window.
This is what I pasted in:
-12","name":{"id":4,"firstName":"Arun","middleName":null,"lastName":"
Antonio","state":"TX","postalCode":"78256-1041","country":"US","countSashidhar","suffix":null},"permanentAddress":{"id":5,"street":
"999 Chase Hill Blvd Apt 922","street2":null,"city":"San
y":null},"mailingAddress":{"id":3,"street":"999
Chase Hill Blvd Apt 922","street2":null,"city":"San
--type":"IND","subType":"UTMA","beneficiary":{"id":7,"name":{"id":8,"fi","emailIsValid":false},"account":{"id":6,"status":"KS","dsad@xxxxxxx
rstName":"Arun","middleName":null,"lastName":"J","suffix":null},"dob"
:"1969-09-18","identification":"2001","identificationType":"SSN","sta
teOfResidence":"NC"},"investment":{"id":10,"investmentOptions":[{"inv
estmentOptionId":"cd","percentContribution":3},{"investmentOptionId":
"de","percentContribution":97}]},"contribution":{"id":13,"amount":100
01.1,"paymentMethod":{"paymentType":"ACH","id":11,"as400Id":0,"routin
gNumber":"999999999","newRoutingNumber":"000000000","bankName":"STATE
UNION","accountNumber":"999999999","accountType":"C","accountName":nuEMPLOYEES CREDIT
ll,"status":"A","preferred":false,"saveForFuture":true},"frequency":"
09:31:33","completedDate":null,"submissionDate":null,"isReadProgramDeONCE"},"application":{"id":9,"startDate":"2020-03-31
scription":true,"isAgreedToTerms":true,"electronicSignature":true},"e
thatJonStatements":true}}
The SQL JSON looked complex. I'll research that idea.
Thx
Jack
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf
Of
Paris
Sent: Monday, May 18, 2020 2:03 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: JSON Error Message
Have you validated the JSON with something like JSONLINT ? I
have found several times that I had invisible characters in
the JSON
DATA-INTOscrewed it up.
It would also help if you showed the json and not just the DS.
Since you are already using SQL to access the JSON why use
thewrote:and not just use the SQL abilities?
On May 18, 2020, at 12:57 PM, Jack Prucha
<Jack.Prucha@xxxxxxx>
a simple proof of concept many months ago and test documents,
I'm working with our web team who is sending me a JSON document.
After
I received the first real output from the web process.
After changing my DS to look more like the output of
YAJLGEN, I'm getting this error message out of YAJLINTO
1002: lexical error: invalid char in json text.█ The parser
for
JSONdata usingDATA-INTO operation detected error code 1002.mark. I don't see any unusual characters when viewing the JSON
The unprintable character displays on a green screen as a
question
Run SQL Scripts or in debug.
Any suggestions about how to fix this? I tried filtering the
withx'40'.hoping to make sure that there's no unprintable characters
under
wrkContent = %ScanRpl(x'000102030405060708090A0B0C0D0E0F' +
'101112131415161718191A1B1C1D1E1F' +
'202122332425262728292A2B2C2D2E2F' +
'303132333435363738393A3B3C3D3E3F':
' ':wrkContent);
We're on 7.3. The web process inserts a record into a db2
file
a.wtContentaCLOB column. This is what the column definition looks like:
Transaction_Content FOR WTCONTENT CLOB ALLOCATE(100) CCSID 37
NOT NULL DEFAULT '' )
This is the JSOSN code from the program:
EXEC SQL DECLARE CWE100R0 CURSOR FOR
SELECT a.wtRecID, a.wtWebID, a.wtSts, a.wtStsDte,
orFROM cvWebTx Aattached to it, has been sent from an email account of College
EXEC SQL FETCH NEXT FROM CWE100R0 INTO
:wtRecID, :wtWebID, :wtSts, :wtStsDte, :wrkContent;
Dcl-s wrkContent SQLTYPE(Clob:128000);
// Extract data from JSON document (cvWebTX.wtContent)
Data-Into txJSONDoc
%Data(wrkContent:'AllowExtra=Yes ' +
'doc=string ' +
'AllowMissing=Yes ' +
'Case=Convert ' +
'CountPrefix=Count_')
%Parser('YAJLINTO':'{"value_null":" "}');
Thanks in Advance
Jack
[CFNC]
This email, including any documents, files, or previous email
messages
Foundation Inc., (CFI) and may contain confidential,
proprietary,
bylegally privileged information belonging to CFI. If you are
not the intended recipient, any dissemination, distribution,
or copying of this email or its attachments is strictly
prohibited. If you have received this email in error, please
immediately notify the sender
postemail and destroy the original email and any attachments.
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To
posta message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,related questions.
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@xxxxxxxxxxxxxxxxxxxx for any
subscription
Help support midrange.com by shopping at amazon.com with our--
affiliate
link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list
To
posta 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@xxxxxxxxxxxxxxxxxxxx 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 IBM i (RPG400-L) mailing list
To
post aa 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@xxxxxxxxxxxxxxxxxxxx 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 IBM i (RPG400-L) mailing list To
unsubscribe,message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,
arelated questions.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@xxxxxxxxxxxxxxxxxxxx for any
subscription
affiliate
Help support midrange.com by shopping at amazon.com with our
link: https://amazon.midrange.com--
This is the RPG programming on IBM i (RPG400-L) mailing list To
post
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,--
unsubscribe, or change list options,
https://archive.midrange.com/rpg400-l.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
related questions.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
affiliate link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
related questions.
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription
affiliate link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
related questions.
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription
link: https://amazon.midrange.com
Help support midrange.com by shopping at amazon.com with our
affiliate
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx 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 IBM i (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@xxxxxxxxxxxxxxxxxxxx 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 IBM i (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@xxxxxxxxxxxxxxxxxxxx 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 IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.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.