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



I concur with the others that in a language such as RPG this is not readily done. However, by constraining the problem space it can be done. I wrote up this technique some 10 years ago http://ibmsystemsmag.com/ibmi/developer/rpg/how-flexible-are-your-calculations-/ <http://ibmsystemsmag.com/ibmi/developer/rpg/how-flexible-are-your-calculations-/> and this followup article which took it one step further.
http://ibmsystemsmag.com/ibmi/developer/rpg/even-more-flexible-calculations/ <http://ibmsystemsmag.com/ibmi/developer/rpg/even-more-flexible-calculations/> providing you know the names of all fields involved, then this could work but I don't think t is the best solution.

Instead in your case I would suggest writing a simple code generator would be a more practical way of handling the multiple parameter sets that you have. Rather than try and write a completely generic program write a generic generator that spits out the RPG to do the JSON to DS mapping for each of your DS. If the parameter set changes regen the code.

Nested structures would be harder to handle but by no means impossible.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Aug 12, 2017, at 3:12 AM, Maria Lucia Stoppa <mlstoppa@xxxxxxxxx> wrote:

Hello,

I am new to this forum, but I have done some research related to JSON and
couldn't find anything similar to my issue.

I am working on a proof of concept to code new programs in order to parse
the only received parameter formed as a JSON object into a data structure.

I explain it better: previously, all our programs received a single
parameter defined as an external data structure, so as soon as *entry plist
operation code is executed the data structure and all the fields in it were
filled in and made available for programs to use them (quite common
solution). External data structure are defined as PF without member and can
be used by any program that need to call the one which received it as a
parameter to perform a specific function.

Now we are moving our ERP's graphic interface to web: it means that a
program call can be executed by a store procedure called either by web
applications or by RPG programs. To serve the purpose of having a quick UI
response, parameters are passed coded in a JSON object and new programs
have been coded to parse JSON input parameter field by field using SK's
JSON APIs (thanks!).

I am guessing whether I can expand and generalize this behavior by coding a
general routine which takes an external definition of JSON (even nested)
structure and assigns each object's name found into JSON parameter to its
corresponding variable name's value.

My nightmares are: firstly, today's external DS are one level only and I
can't figure out how to represent nested levels; secondly how to
dynamically associate the value of JSON pair to its corresponding
variable's value according to its type.

One general idea might be to code some external D specifications to be used
through /COPY option, which represent JSON structure in terms of qualified
names and types, array included. Then JSON objects can be read element by
element but how can I address the right DS variable without explicitly
write its name?

Can you suggest me some technique I haven't explored yet or any other way
to approach the problem?

Thank you


--

Maria Lucia Stoppa
mlstoppa@xxxxxxxxx
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://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: http://amzn.to/2dEadiD


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.