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



+1 on the SQL approaches don't have to be as hard as they look at first - I learned that with XMLTABLE - most of it is just like CREATE TABLE, just have to get the source of the XML specified, plus paths to where the data item is located.

I've not tried the aggregation stuff yet, yet those should be manageable, too.

Regards
Vern

On 5/18/2020 3:00 PM, Jay Vaughn wrote:
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 this
document to see how you can easily build complicated json structures.
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 different related objects).

https://jeffersonvaughn.com/gallery/coreiRST%20Overview.pdf

Jay

On Mon, May 18, 2020 at 2:33 PM Jack Prucha <Jack.Prucha@xxxxxxx> wrote:

Hello Jon,

I attended your RPG/DB2 seminars in the suburbs of Chicago. Although I
live far from there now I grew up a few miles away from the hotel. It 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 out of
the Run SQL Scripts result window.

This is what I pasted in:
{"id":1,"userId":10415785,"accountNumber":null,"dateOfBirth":"1999-08-12","name":{"id":4,"firstName":"Arun","middleName":null,"lastName":"Sashidhar","suffix":null},"permanentAddress":{"id":5,"street":"999
Chase Hill Blvd Apt 922","street2":null,"city":"San
Antonio","state":"TX","postalCode":"78256-1041","country":"US","county":null},"mailingAddress":{"id":3,"street":"999
Chase Hill Blvd Apt 922","street2":null,"city":"San
Antonio","state":"TX","postalCode":"78256-1041","country":"US","county":null},"identification":"2001","identificationType":"SSN","contact":{"id":2,"mobilePhone":"","textOptIn":false,"homePhone":"","workPhone":"","email":"
dsad@xxxxxxx","emailIsValid":false},"account":{"id":6,"status":"KS","type":"IND","subType":"UTMA","beneficiary":{"id":7,"name":{"id":8,"firstName":"Arun","middleName":null,"lastName":"J","suffix":null},"dob":"1969-09-18","identification":"2001","identificationType":"SSN","stateOfResidence":"NC"},"investment":{"id":10,"investmentOptions":[{"investmentOptionId":"cd","percentContribution":3},{"investmentOptionId":"de","percentContribution":97}]},"contribution":{"id":13,"amount":10001.1,"paymentMethod":{"paymentType":"ACH","id":11,"as400Id":0,"routingNumber":"999999999","newRoutingNumber":"000000000","bankName":"STATE
EMPLOYEES CREDIT
UNION","accountNumber":"999999999","accountType":"C","accountName":null,"status":"A","preferred":false,"saveForFuture":true},"frequency":"ONCE"},"application":{"id":9,"startDate":"2020-03-31
09:31:33","completedDate":null,"submissionDate":null,"isReadProgramDescription":true,"isAgreedToTerms":true,"electronicSignature":true},"eStatements":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 Jon
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 that screwed 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 DATA-INTO and
not just use the SQL abilities?


On May 18, 2020, at 12:57 PM, Jack Prucha <Jack.Prucha@xxxxxxx> wrote:

I'm working with our web team who is sending me a JSON document. After
a simple proof of concept many months ago and test documents, 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 the
DATA-INTO operation detected error code 1002.

The unprintable character displays on a green screen as a question
mark. I don't see any unusual characters when viewing the JSON data using
Run SQL Scripts or in debug.
Any suggestions about how to fix this? I tried filtering the JSON
hoping to make sure that there's no unprintable characters under x'40'.

wrkContent = %ScanRpl(x'000102030405060708090A0B0C0D0E0F' +
'101112131415161718191A1B1C1D1E1F' +
'202122332425262728292A2B2C2D2E2F' +
'303132333435363738393A3B3C3D3E3F':
' ':wrkContent);

We're on 7.3. The web process inserts a record into a db2 file with a
CLOB 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, a.wtContent
FROM cvWebTx A

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
attached to it, has been sent from an email account of College Foundation
Inc., (CFI) and may contain confidential, proprietary, or legally
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 by email and destroy the
original email and any attachments.
--
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 thread ...

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.