This worked great!

I had not heard of the command either... I was surprised to find it when I Googled how to "unzip files on IBM i" (I may have used as400 instead)

Thanks Scott!

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Friday, March 29, 2024 8:34 AM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Unzipping JSON files then parsing.

Personally, I think it's probably a good assumption to assume that the extracted JSON files will always be UTF-8.  That's pretty much the standard for JSON. I know people (especially on IBM i) will sometimes store them in EBCDIC, but it's usually only temporary.  Stuff stored permanently or sent over a network is pretty much always UTF-8.

Assuming you agree...  just add some code to do CHGATR
OBJ('/path/to/file.json') ATR(*CCSID) VALUE(1208) on each file before you read it in your program.  This forces the CCSID to 1208, so it should be interpreted correctly.

Background:  Storing the CCSID of a file in the filesystem is a unique-ish feature of IBM i. This concept is unknown to other platforms like Windows.  ZIP files, therefore, do not have a way to store the CCSID of the file.  they don't know what your CCSID should be!  It sounds like the CPYFRMARCF tool (I've not heard of this tool before) assumes that all files it extracts should be assigned the system ccsid (which for US systems is likely 37).  So you'll always get 37 instead of the actual format of the file.  As such, you will need to "know" the true CCSID and use CHGATR to set it properly.


On 3/28/24 4:05 PM, Greg Wilburn wrote:
I'm having an issue parsing JSON files with YAJLINTO.

I have an FTP Script that retrieves .ZIP files (containing the JSON files) from our FTP server.
I then use CPYFRMARCF to extract the JSON files on the IFS.

From there, I am able to open them with Firefox or Notepad, but I cannot use WRKLNK to read them.

The CCSID of the zip file is 819
The CCSID of the extracted JSON files is 37

I don't see how to control the CCSID of the JSON file(s) created by CPYFRMARCF (assuming this is my problem).
If I extract on the PC, Notepad tells me the files are UTF-8.

Any input would be appreciated.
(I'm out until Monday)

Thanks,
Greg

The actual error is:

Message ID . . . . . . : RNX0453 Severity . . . . . . . : 50
Message type . . . . . : Escape
Date sent . . . . . . : 03/28/24 Time sent . . . . . . : 16:45:30

Message . . . . : An error occurred during conversion from CCSID(1208) to
CCSID(937).
Cause . . . . . : In RPG procedure GET_INPUT_ in program YAJL/YAJLINTO, an
error occurred during conversion of data between CCSID(1208) and CCSID(937)
Recovery . . . : Check the joblog for previous messages, and contact the
person responsible for program maintenance to determine the cause of the
problem.
[Logo]<https://www.totalbizfulfillment.com/> Greg Wilburn
Director of IT
301.895.3792 ext. 1231
301.895.3895 direct
gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@totalbizfulfillment.c
om>
1 Corporate Dr
Grantsville, MD 21536
www.totalbizfulfillment.com<http://www.totalbizfulfillment.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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.