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



Scott,

This works perfectly. Thank you! I don't know how you find the time to help us all.

Hope to see you in person one day again. I was at several of the rpg/db2 summits in the Chicago suburbs where I grew up many years ago.

Thanks again

Hi Jack,

I suspect the problem is you're trying to create a node with a blank name instead of another object, and its putting the generator into a bad state. Unless I'm misunderstanding, you don't want/need to give the node a name (not even blank) and you don't want to generate an extra object. So the code would be more like this:

rc = yajl_genOpen(*On);
ptrJSONContent = %Addr(wrkContent_Data);
lenJSONContent = wrkContent_Len;
Root = yajl_buf_load_tree(ptrJSONContent:lenJSONContent:errMsg);
rc = yajl_genFromNode(*omit:Root);
yajl_tree_free(Root);
rc = yajl_saveBuf('/tmp/prettyJSON.json':errMsg);
yajl_genClose();

-SK


On 10/28/2020 1:39 PM, Jack Prucha wrote:
Nothing blows up or returns errors but this code only returns a single '{' in the buffer so I'm probably doing several things wrong. I'm very unsure about yajl_genfromNode.

Dcl-s Root Like(yajl_val);
Dcl-s errMsg VarChar(500) Inz(' ');
Dcl-s ptrJSONContent Pointer;
Dcl-s rtnLen Int(10);
Dcl-s lenJSONContent Int(10);
Dcl-s wrkContent SQLTYPE(Clob:128000);

EXEC SQL
SELECT a.Transaction_Content
INTO :wrkContent
FROM cvWebTx A
WHERE a.AppID = :wrkRecID;

rc = yajl_genOpen(*On);

ptrJSONContent = %Addr(wrkContent_Data);
lenJSONContent = wrkContent_Len;
Root =
yajl_buf_load_tree(ptrJSONContent:lenJSONContent:errMsg);

rc = yajl_beginObj();

rc = yajl_genFromNode(' ':Root);

rc = yajl_endObj();

rc = yajl_saveBuf('/tmp/prettyJSON.json':errMsg);

yajl_genClose();

I appreciate other suggestions about other open source. Since YAJL is already installed and being used I'd like to stick with it.

If your requirements are different and its important to do this in program code... this is unusual, but should be possible with YAJL. Open an existing JSON document into a tree using yajl_stmf_load_tree() (or one of the other yajl tools that loads a tree) and then use YAJL's generator to create output. There's a routine called YAJL_genFromNode that you can call, pass a node (such as the document node returned by
yajl_stmf_load_tree) and it will add that entire tree to the generated JSON. If you've configured the JSON generate to generate in "pretty"
format, the yajl_genFromNode will essentially copy the structure, but the output will be "pretty".

Good Luck


On 10/27/2020 3:09 PM, Jack Prucha wrote:
I want to present a JSON payload to the user in an easy-to-read format. Output like JSONFormatter.org. Linking to a web site is a non-starter so I'm searching for something iSeries based.

I have Scott's YAJL software installed and am using it with Data-Into. However, I don't see an example in his thorough documentation to take any JSON and pretty up the formatting for human viewing. There's a CLE pgm in his YAJLLIB72 called JSON_Refmt but I can't figure it out.

Most RPGLE JSON open source I see is designed to create or disassemble JSON - not display it.

Any suggestions?

TIA
Jack





[CFNC]

This email, including any documents, files, or previous email messages attached to it, has been sent from an email account of College Foundation Inc., (CFI) and may contain confidential, proprietary, or legally privileged information belonging to CFI. If you are not the intended recipient, any dissemination, distribution, or copying of this email or its attachments is strictly prohibited. If you have received this email in error, please immediately notify the sender by email and destroy the original email and any attachments.

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.