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



Scott, Jon, Joe & Alan. I'm giving that a try right now.

Thanks for the quick replies!

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, May 08, 2019 2:14 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: JSON DS & Data-Into

Your JSON document is difficult to read (I think the e-mail software is causing havok with it, converting things to links, html, etc).

But, I think the basic mistake you're making is trying to treat this as
3 different documents, instead of one document.

The structure should be:

dcl-ds MyJsonDoc qualified;
   dcl-ds documentHistoryEvents dim(100);
      // subfields here
   end-ds;
   dcl-ds participants dim(100);
       // subfields here
   end-ds;
   status char(20);
   documentKey char(50);
end-ds;

Notice how documentHistoryEvents, participants, status and documentKey are all subfields of a data structure?  that's because in your JSON document you have this:

{
  "documentHistoryEvents": <value>,
  "particpants": <value>,
  "status": <value>,.
  "documentKey": <value>
}

The curly braces basically mean "data structure", so the fact that the
whole thing is inside a set of { and } characters mean that your whole
RPG result must also be in a data structure. Yes, I know the outermost
curly braces don't have any name assigned to them, that's normal (and in
fact is always the case in JSON, the outermost element cannot have a
name in JSON).   That's ok, you can call it whatever you like on the RPG
side (I used "MyJsonDoc", above.)

Then code:

data-into MyJsonDoc %data(ResponseStr:'case=convert') %parser('YAJLINTO');

Though, you may want to use countprefix to determine how many
documentHistoryEvents and participants you received.

What it all boils down to is this:  the RPG structure must match the
JSON document structure.

-SK


On 5/8/2019 12:47 PM, Jack Prucha wrote:
Hopefully someone can help me with the various DS definitions and the necessary parameters on the Data-Into command.

This is my first experience with JSON as the web guy asked if we can read it or does he have to create another flat file.

This was partially working when I first put together a test pgm using Scott's YAJL and the various subprocedure calls to process JSON. I got the Data-Into PTFs installed (7.3), switched the parser to YAJLINTO and now I'm realizing that my JSON document is complex. There are three JSON "objects" or data structures in the incoming document. It doesn't matter if I have to process the document three times or can do it all once.

The document looks like this:

{"documentHistoryEvents":[{"type":"Created","date":"2019-04-01T20:33:13.485564Z","description":"Created by external_web_esig@xxxxxxx","participantEmail":"external_web_esig@xxxxxxx","actingUserIpAddress":"66.194.20.120"},{"type":"Sent","date":"2019-04-01T20:33:15.048387Z","description":"Sent<mailto:external_web_esig@xxxxxxx%22,%22participantEmail%22:%22external_web_esig@xxxxxxx%22,%22actingUserIpAddress%22:%2266.194.20.120%22%7d,%7b%22type%22:%22Sent%22,%22date%22:%222019-04-01T20:33:15.048387Z%22,%22description%22:%22Sent> by external_web_esig@xxxxxxx","participantEmail":"external_web_esig@xxxxxxx","actingUserIpAddress":"66.194.20.120"},{"type":"Viewed","date":"2019-04-01T20:33:40.774774Z","description":"Viewed<mailto:external_web_esig@xxxxxxx%22,%22participantEmail%22:%22external_web_esig@xxxxxxx%22,%22actingUserIpAddress%22:%2266.194.20.120%22%7d,%7b%22type%22:%22Viewed%22,%22date%22:%222019-04-01T20:33:40.774774Z%22,%22description%22:%22Viewed> by test@xxxxxxx","participa!
ntEmail":
"test@xxxxxxx","actingUserIpAddress":"66.194.20.120"}],"participants":[{"email":"external_web_esig@xxxxxxx","name":"Program<mailto:test@xxxxxxx%22,%22participantEmail%22:%22test@xxxxxxx%22,%22actingUserIpAddress%22:%2266.194.20.120%22%7d],%22participants%22:[%7b%22email%22:%22external_web_esig@xxxxxxx%22,%22name%22:%22Program> Administrator"},{"email":"external_web_esig@xxxxxxx<mailto:external_web_esig@xxxxxxx>","name":"Program Administrator"},{"email":"test@xxxxxxx<mailto:test@xxxxxxx>","name":"SMILEY ALMENDAREZ"}],"status":"Viewed","documentKey":"Lzq8e8o8tmFYi2viZphuHh"}

There's a documentHistoryEvents, participants, and an unnamed object. It's formatted correctly as I had the web guy show me using one of the online formatters.

My Data structures and code are defined as follow:

Dcl-ds documentHistoryEvents Dim(100) Qualified;
Type Char(20);
Date Char(28);
Description Char(50);
ParticipantEmail Char(50);
ActingUserIPAddress Char(50);
End-Ds;

Dcl-ds participants Dim(100) Qualified;
EMail Char(50);
name Char(50);
End-Ds;

Dcl-ds DocStatus Qualified;
status Char(20);
documentKey Char(50);
End-Ds;

Dcl-s ResponseStr VarChar(16000000);

// Load JSON Document into DS
Data-Into documentHistoryEvents %Data(ResponseStr:'Case=Any -
Doc=String ')
%Parser('YAJLINTO');

ResponseStr has the JSON loaded from a website using an HTTP call. I've tried processing just the documentHistoryEvents document using combinations of path, allowextra and countprefix options, but I keep getting RNX0356 reason code 5 when executing. I understand the layouts of the DS should match the JSON fields but not sure what to do with multiple documents and an unnamed document.

TIA
Jack Prucha
Programming Team Supervisor

College Foundation, Inc.
Office Phone: 919.835.2530

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.


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.