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



Base64 always preserves the binary value of the data.  That's what it's all about.  So if you want the data to be decoded in (which is weird for an application newer that 1998 -- ASCII has mostly been replaced with unicode.)

Your steps will look like this:

1) Get the ASCII data (in ASCII format) and encode it in base64.

2) Put the encoded data in your JSON field.  If the JSON building tool you're using is expecting input in EBCDIC, make sure you've converted the base64-encoded string to EBCDIC (it won't change the underlying values once decoded.)

3) Create your JSON document (which should be encoded in UTF-8 --a version of Unicode -- that's the standard for JSON -- which means your encoded string will also be encoded in UTF-8... again, it won't change the underlying value.)

4) Encode the JSON document in base64 as well.

5) Send the result whereever it needs to go.

As for IBM-supplied APIs.  They provide the Apache Portable Runtime (APR) which has base64 routines, I'm not a huge fan, but they exist.  SQL also has a base64 function, that works nicely, aside from the fact that it has a relatively short string length, which can be an issue sometimes.

For creating JSON, I would either use SQL or DATA-GEN. Personally, I prefer the latter -- I find it easier and more elegant, other people prefer SQL...  both will do the job.

-SK

On 8/8/2023 6:05 PM, Vinay Gavankar wrote:
Hi,

I want to create a JSON string where one of the fields needs to be BASE64
encoded. The JSON string will then be converted to ASCII to be sent out to
be used by an ASCII based server.
For example,
{
"Field1" : "aaa",
"Field2" : "bbb",
"Field3" : "ccc"
}
where Value bbb needs to be BASE64 encoded.
I am assuming that BASE64 encoding of EBCDIC and ASCII will give different
results, and just encoding bbb in EBCDIC before creating JSON string and
then converting full string to ASCII will not do the trick. Is that correct?
Also, what is the best way of BASE64 encoding/decoding using IBM supplied
APIs?

Any ideas will be greatly appreciated. TIA

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.