Hi Scott,

The YAJLGEN utility is just what I was looking for. Thank you.

I used YAJLGEN to generate the programs for 2 different files. The first one worked like a charm. The second threw an error: RNX0356 The document for the DATA-INTO operation does not match the RPG variable; reason code 7.

Cause . . . . . : While parsing a document for the DATA-INTO operation, the parser found that the document does not correspond to RPG variable "jsondoc" and the options do not allow for this. The reason code is 7. The exact subfield for which the error was detected is "jsondoc.ratemap.pitd(1).accessorialcharges(1)". The options are "doc=file case=convert countprefix=num_". The document name is /markl/ReturnSample.json; *N indicates that the document is not an external file. The parser is 'YAJLINTO'. *N indicates that the parser is a procedure pointer.

Reason code 7: The document contains subfield items for RPG scalar fields, subfields or array elements.

The incoming data has the following: "accessorialCharges": [], so the program seems to be choking on the empty array.

-mark

On 12/30/2019 12:31 PM, Scott Klement wrote:
Mark,

The caveat to YAJLGEN is that there's a lot of information that RPG needs that simply isn't in the JSON file. For example, the JSON file may tell you there's an array, but it doesn't tell you how many maximum elements the array could ever hold. Likewise, it can tell you there's a string, but it doesn't tell you the maximum size that can ever be in a string.

But, it does the best it can, and you can go in and tweak the RPG code as needed.

Let me know how it works for you,

-SK


On 12/30/2019 9:45 AM, mlazarus wrote:
Thanks!

On 12/30/2019 8:47 AM, Greg Wilburn wrote:
Scott's YAJLGEN command works GREAT to create a base data structure for you using a JSON sample on the IFS.
Very nice utility to complement YAJLINTO.

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Bryan Dietz
Sent: Thursday, December 26, 2019 1:37 PM
To: RPG programming on IBM i<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Utility to map JSON into the corresponding DS layout?

have you seen Scott's YAJL ?
http://www.scottklement.com/yajl/

<snip>
Note: Updated July 29, 2019 added YAJLGEN utility, and ability to write
*STDIN data to IFS.

Note: Updated November 25, 2019 added YAJLDTAGEN (DATA-GEN interface),
and yajl_addPreformattedPtr routine.
</snip>


maybe that will work?

Bryan



mlazarus wrote on 12/26/2019 1:12 PM:
I am looking for an automated way to take a sample JSON file and build
the corresponding DS in RPG. Is there a utility for that? Or maybe
something built into RDi?

I thought there was a Midrange discussion about this a while back, but
can't seem to locate it. TIA.

-mark

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.