YAJL_GET_STRING UTF8

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
captainfruitbat
Posts: 6
Joined: Thu Sep 12, 2024 11:21 pm

YAJL_GET_STRING UTF8

Post by captainfruitbat »

I have a legacy RPGLE program that uses YAJL to parse JSON data from the IFS into a character column in an IBM i database table. This has been working well for years when the incoming data was basic ASCII and the table column was EBCDIC. We now need to handle a much broader set of characters. The JSON data in the IFS is UTF8, and I have a test version of the database table with the relevant field defined with the UTF8 CCSID (1208). I was hoping that using YAJL_GET_STRING to retrieve the IFS data into the database field would keep it all in UTF8, but it seems to return EBCDIC data - I'm guessing it is using the job CCSID (37 in our case) to do implicit conversion. Any suggestions for how I can get the UTF8 data into my database table?

If it helps, the IBM i is on 7.2, QCCSID 65535 (Yes, I know..... not under my control), QLANGID 37.
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: YAJL_GET_STRING UTF8

Post by Scott Klement »

Please use YAJL_GET_STRING_UTF16().

Even if the variable in your RPG program is coded with ccsid(*utf8) or ccsid(1208), this should work properly. (RPG will automatically translate it to UTF-8 for you.)

But, I would recommend that you use UTF-16 in your database. IBM has always recommended that database fields use UTF-16 rather that UTf-8. It performs much better, and the support is far more complete.

UTF-8 is great for network transfers because it is smaller. But UTF-16 is the one you want to use inside your application if at all possible.
captainfruitbat
Posts: 6
Joined: Thu Sep 12, 2024 11:21 pm

Re: YAJL_GET_STRING UTF8

Post by captainfruitbat »

Thanks Scott - will give that a try. Your comments about using UTF-16 in the database are noted, and I will make that change.
captainfruitbat
Posts: 6
Joined: Thu Sep 12, 2024 11:21 pm

Re: YAJL_GET_STRING UTF8

Post by captainfruitbat »

It turns out the version of YAJL on this IBM i does not have YAJL_GET_STRING_UTF16. Must be quite old. I will get it updated to the latest version. When I install the new YAJL version, do I need to identify and recompile any RPGLE programs that use it? I will use the same library name for YAJL.
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: YAJL_GET_STRING UTF8

Post by Scott Klement »

No, it's backward compatible... everything will work without any recompiles
captainfruitbat
Posts: 6
Joined: Thu Sep 12, 2024 11:21 pm

Re: YAJL_GET_STRING UTF8

Post by captainfruitbat »

Fantastic - thanks Scott
Post Reply