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



Booth - It appears you have a valid node from opening the doc but since I can't find a copy in the thread of your actual JSON I can't make much of a suggestion as to what to look for next.

Can you give us an extract of the JSON and also a repeat of the first few lines of RPG after the tree build.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Aug 24, 2017, at 4:04 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

What does the JSON look like Booth - I've forgotten if I ever knew.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Aug 24, 2017, at 3:47 PM, Booth Martin <booth@xxxxxxxxxxxx> wrote:

The parsing, etc. works. Not as elegantly as your example though! This is getting tucked away for future reference. Thank you.

As the Subject says, retrieving the JSON data is where it fails.

docNode = yajl_stmf_load_tree('home/bmartin/Louie.json': errMsg );
if errMsg = '';

node = YAJL_object_find(docNode: 'success');
result.success = YAJL_is_true(node);

node = YAJL_object_find(docNode: 'errmsg');
result.errmsg = YAJL_get_string(node);

list = YAJL_object_find(docNode: 'list');

...

The directory is copy/paste from wrklnk.
Louie.json has valid data.
Run in debug, errMsg is blank, list is empty.

On 8/23/2017 2:53 PM, Slanina, John wrote:
I don't know what you're looking for but here is one. I spend all day write JSON CODE.

Thanks
John Slanina


begsr parseOK;

// Clear out any control characters, replace with blanks
gXmlResponse = %ScanRpl(x'0D' : '' : gXmlResponse );
gXmlResponse = %ScanRpl(x'25' : ' ' : gXmlResponse );
gXmlResponse = %ScanRpl(x'00' : ' ' : gXmlResponse );

docNode = yajl_buf_load_tree(%addr(gXmlResponse:*data) : %len(gXmlResponse) : JsonErrMsg);
items = YAJL_object_find(docNode: 'items');
links = YAJL_object_find(docNode: 'links');

i = *zeros;

dow YAJL_ARRAY_LOOP( items : i: val );

clear ofiupd01Ds;

Node = YAJL_object_find(val : 'inventoryId');
ofiupd01DS.CBJJA4 = YAJL_get_Number(Node);

Node = YAJL_object_find(val : 'serialNumber');
ofiupd01DS.CBWPCS = YAJL_get_string(Node);

Node = YAJL_object_find(val : 'item_number');
ofiupd01DS.CBSXBT = YAJL_get_string(Node);

ofiupd01DS.CBJKA4 = resourceId_P;

Node = YAJL_object_find(val : 'status');
ofiupd01DS.CBW3CS = YAJL_get_string(Node);

ofiupd01DS.CBACDT = %dec(%date():*cymd);
ofiupd01DS.CBACTM = %dec(%Time():*ISO);
ofiupd01DS.CBH6NB = PGMSDS.JOB_NUM;
ofiupd01DS.CBADVN = PGMSDS.PROC_PGM;
ofiupd01DS.CBAFVN = PGMSDS.JOB_USER;

// Delete the prior value of this record if in file and replace.
delete (ofIupd01Ds.CBJJA4) ofiupd01;
write ofIup01f ofIupd01Ds;
enddo;

i = *zeros;

dow YAJL_ARRAY_LOOP( links : i: val );

Node = YAJL_object_find(val : 'rel');
relVal= YAJL_get_string(Node);
if relVal = 'next';
Node1 = YAJL_object_find(val : 'href');
uri = YAJL_get_string(Node1);
Endif;

enddo;

endsr;


{
"totalResults": 1482,
"limit": 10,
"offset": 0,
"items": [
{
"inventoryId": 28282912,
"status": "resource",
"serialNumber": "PKGRVSSQG",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282912";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 26351924,
"status": "resource",
"serialNumber": "A9200019076F452",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "TIVMINI",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/26351924";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282903,
"status": "resource",
"serialNumber": "PKGTVKSQK",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282903";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282916,
"status": "resource",
"serialNumber": "PKCPJXJPT",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282916";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282913,
"status": "resource",
"serialNumber": "PKGSQQXLD",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282913";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282914,
"status": "resource",
"serialNumber": "PKCQVPWNR",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282914";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282900,
"status": "resource",
"serialNumber": "PKCQKGSSV",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282900";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282902,
"status": "resource",
"serialNumber": "PKGTMCDGG",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282902";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282832,
"status": "resource",
"serialNumber": "EVY616D22179",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "EDTA200",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282832";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
},
{
"inventoryId": 28282898,
"status": "resource",
"serialNumber": "PKCPXJNLS",
"quantity": 1,
"resourceId": "81333",
"resourceInternalId": 259,
"item_number": "S425HDC",
"port_info": "1:C",
"icoms_techid": "81333",
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/inventories/28282898";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/inventories";
}
]
}
],
"links": [
{
"rel": "canonical",
"href": "https://api.etadirect.com/rest/ofscCore/v1/resources/81333/inventories";
},
{
"rel": "describedby",
"href": "https://api.etadirect.com/rest/ofscCore/v1/metadata-catalog/resources#definitions/inventories";
},
{
"rel": "next",
"href": "https://api.etadirect.com/rest/ofscCore/v1/resources/81333/inventories?offset=10";
}
]
}



-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Booth Martin
Sent: Wednesday, August 23, 2017 3:37 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: RPG, retrieving JSON data from a web service

are there a couple of examples of other programmer's versions of using Scott Klement's YAGL library to retrieve JSON data? I am missing some important aspect. Whether it is a typo, a total mess-up, or what I do not know. I am thinking that perhaps if I see how others have used his hard work then I will have it working too.

I can retrieve the data with javascript in a non-iSeries environment so I am presuming I have a stupid tucked away in there and am being blind to it.


On 8/20/2017 5:58 PM, Booth Martin wrote:
I am failing to understand something.

* I am using Scott Klement's YAJL library for the iSeries.
--
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: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://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: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://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 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.