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



Hi all,
Hope you all are doing well.

I am working on an SQLRPGLE program to provide JSON data using SK YAJL
functions.
Everything works as expected except I would like to use another JSON object
as an attribute's value.
I'll explain it better.
This is the DS I populate at the end of my web service program (let's call
it 'main program')
dcl-ds stdOutput qualified inz;
success ind inz(*off);
errCode char(7);
message varchar(128);
data varchar(31000);
end-ds;
'data' is a variable filled with different content depending on the program
called by the main program, and when JSON output is written at the end of
the main program *'data' has already been formatted as a JSON object by the
called program*, which of course has returned it as a string.

Now, when using this code
YAJL_beginObj();
YAJL_addBool('success' : stdOutput.success);
YAJL_addChar('errCode' : stdOutput.errCode);
YAJL_addChar('message' : stdOutput.message);
YAJL_addChar('data' : %trim(stdOutput.data));
YAJL_beginObj('data');
YAJL_endObj();

YAJL_copyBuf(CCSID
: %addr(jsonData)
: %size(jsonData)
: wRetLen);
YAJL_genClose();

to write JSON output, 'stdOutput.data' value is treated as a string,
meaning the JS consumer must parse it into a JSON object to be able to use
it. This is not so bad to do if there are no other choices.

Only, I wonder if there is a way to even add an already set object to the
final JSON. I made some tries with YAJL_copyBufPtr and adding an object
named 'data' omitting the first parameter, all without success.

Am I trying something impossible or missing the elephant in the room?

Thank you


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.