|
On Sep 15, 2017, at 10:28 AM, Slanina, John <jslanina@xxxxxxxxxx> wrote:
Bradley,
It is a web service call using RXS-XML library the whole JSON Document comes back in a string.
With I then I do this code.
But I want the array element node "VAL" to be logged not docnode.
docNode = yajl_buf_load_tree(%addr(gXmlResponse:*data) : %len(gXmlResponse) : JsonErrMsg);
Node = YAJL_object_find(docNode : 'found');
if YAJL_IS_TRUE(Node);
//
// Update NextPage
//
chain (Subscription_P) ofsupd01 ofsupd01Ds;
if not %found(ofsupd01);
exsr Exitpgm;
endif;
Node = YAJL_object_find(docNode : 'nextPage');
nextPage = YAJL_get_string(Node);
ofsupd01Ds.nextPage = nextPage;
ofsupd01Ds.LastPollDate = %dec(%date():*cymd);
ofsupd01Ds.LastPollTime = %dec(%Time():*ISO);
ofsupd01Ds.LastPollStatus = 'G';
update ofsup01f ofsupd01Ds;
items = YAJL_object_find(docNode: 'items');
i = *zeros;
dow YAJL_ARRAY_LOOP( items : i: val );
Node = YAJL_object_find(Val : 'eventType');
eventType = YAJL_get_string(Node);
clear oftrtv01Ds;
chain (Subscription_P : eventType) oftrtv01 oftrtv01Ds;
if %found(oftrtv01);
if oftrtv01Ds.Program <> 'NA' and oftrtv01Ds.status = 'A';
monitor;
writeJobLog('Calling ' + %trim(eventType) + ' ' + %trim(oftrtv01Ds.Program) + X'25');
program(eventType : val );
on-error;
writeJobLog('*** ERROR *** Calling ' + %trim(eventType) + ' ' +
%trim(oftrtv01Ds.Program) + X'25');
endmon;
endif;
endif;
enddo;
endif;
Val is the one I want to convert to a string which is an Object not a string .
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Bradley Stone
Sent: Friday, September 15, 2017 9:48 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Convert JSON object to String.
John,
How are you getting the JSON data into your program? From a POST using standard input?
Bradley V. Stone
www.bvstools.com
MAILTOOL Benefit #12 <https://www.bvstools.com/mailtool.html>: Both Text and HTML email support
On Fri, Sep 15, 2017 at 8:11 AM, Slanina, John <jslanina@xxxxxxxxxx> wrote:
Does anyone know using Scott Klement Json Library how you can convert--
an JSON object back to a string so I can log the file ?
I have a json array and I want to log each element within the array to
a file.
Thanks
John Slanina
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx 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: http://amzn.to/2dEadiD
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
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: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
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: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
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.