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



Stephen,

I don't understand why you're using yajl_stringify or yajl_stringifystr?  This is for taking a part of a parsed JSON document and turning it back to the JSON source.   Given your requirements, I can't see why you'd use this.

1. I've had good luck with graphic fields defined with CCSID 1200.  You define this as the number of characters so you'd use 100.  Since UTF-16 uses 2 bytes per character, it'll occupy 200 bytes of storage under the covers, but you define it as 100 characters.

2. Not sure the system CCSID is relevant here.   You want to avoid translating it to EBCDIC, this is where you'll run into problems if you want to support all possible languages you want to make sure you stay with Unicode.   If you stick with Unicode it won't matter which EBCDIC CCSID is defined in the system or job values.

Unfortunately, YAJL doesn't provide a built-in way of returning data in UTF-16 at this time.   If you were on a newer release, you could use DATA-INTO, which would work well with UTF-8, but 7.1 does not support DATA-INTO.  YAJL supports returning data either in UTF-8 (it uses this for all of its processing under the covers) or with my extensions it supports EBCDIC, which isn't what you want.

Your best bet would be to use yajl_get_string_utf8, that will give you a pointer to the UTF-8 (which is Unicode) string.  You would then have to use iconv() or similar to convert it from UTF-8 to UTF-16 for the database.   Newer RPG versions provide direct support for this type of translation, but alas, 7.1 does not, so you'll need to use iconv().

The other possibility would be to add support into my YAJL extensions for something like YAJL_GET_STRING_UTF16 that would return the data exactly as you want it.

-SK


On 3/5/2019 2:49 PM, Stephen Piland wrote:
The requirements are to read / decode a JSON file on the IFS and save the multilanguage value to a column in DB2 table (on i). For now, we just want to be able to view it in ACS SQL to verify and will use it down the road in a JSON we will create. I have reviewed but am not 100% clear this article (https://www.fieldexit.com/forum/display?threadid=321). I was trying to piece together enough from there and in the newest YAJL sample files and I kind of punted when I found that YAJL_stringifyStr seemed to work. It was just slow.

Here is the little bit of code so far..
Val = YAJL_object_find(node1 : 'value');
LANGVAL = %trim(YAJL_stringifyStr(val); // LANGVAL is DB column vargraphic(101) with CCSID 13488

1. How should the column be defined in the table? CSSID? Data type? Length? If I'm wishing it to be 100 en_us characters, should it be defined as 200 due to DBCS?
2. System is not set to CCSID 37, so should job run using CCSID 37?

Language 'Array'....

[
{ "lang" : "de_de", "value" : "No Communication Label" },
{ "lang" : "en", "value" : "No Communication Label" },
{ "lang" : "en_gb", "value" : "No Communication Label"},
{ "lang" : "en_us", "value" : "No Communication Label"},
{ "lang" : "es_es", "value" : "No Communication Label"},
{ "lang" : "fr", "value" : "Aucun libellé de communication"},
{ "lang" : "ja_jp", "value" : "春夏预告系列"},
{ "lang" : "ko_kr", "value" : "No Communication Label"},
{ "lang" : "pt_br", "value" : "No Communication Label"},
{ "lang" : "ru_ru", "value" : "Пре-Коллекция Весна-Лето "},
{ "lang" : "th_th", "value" : "No Communication Label"},
{ "lang" : "zh_cn", "value" : "No Communication Label"},
{ "lang" : "zh_tw","value" : " 春夏 プレコレクション"}
]

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Tuesday, March 5, 2019 12:46 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Processing Multilanguage Data with YAJL, RPG and a PF

Hello,

Its not clear what problem you're trying to solve or what roadblocks you're hitting.  Please take a step back and give us some context?

Thanks!

-SK

On 3/4/2019 9:57 AM, Stephen Piland wrote:
I see prior posts but did not know how to reply to that thread...

Did someone get this to actually work? I tried what I thought was the simplest path but never could get Brad Stone's example to get past precompile failures on the statement...
Exec sql Declare :value VARIABLE CCSID 1208;

System is running 7.1. I'm going to try the ICONV next but thought there might be a quick trick.

Basically, we are just trying to decode an incoming JSON that has a variety of languages in some element/nodes. Then we want to save to table/file (CCSID 13488/1200 perhaps on that field/column. Down the road, we'll grab that value and create an outbound JSON to send to a REST API.

YAJL Stringify does seem to work but it super slow, so I'm looking at alternatives.

Any suggestions would be greatly appreciated!
--
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@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com

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.