Bradley,
Thanks for your time and I got it.
Dawned on me I needed to set yet another pointer for "EquipmentHeader" before I could move on to "UnitInstallDateTime".
Thanks for your help and have a great day !
Scott
________________________________
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Scott Webster <as400guru@xxxxxxx>
Sent: Tuesday, June 25, 2019 11:46 AM
To: RPG programming on IBM i
Subject: Re: YAJL and nested node names
Bradley,
Really feeling slow today.
So, using your example I get a valid pointer to "Equipment". So far so good.
I process the loop. The keys I see are the sub nodes (?) EquipmentHeader & Location.
Now I need to process the elements within each sub node (first - UnitInstallDateTime).
I thought I could use YAJL_object_find against either the "list" or "node" pointers. Wrong.
docNode = yajl_stmf_load_tree('/tmp/JLGCSKBAS.json': errMsg );
if errMsg <> '';
// handle error
endif;
node = YAJL_object_find(docNode: 'Fleet');
list = YAJL_object_find(node: 'Equipment');
i = 0;
dow YAJL_ARRAY_LOOP( list: i: node );
j = 0;
dow YAJL_OBJECT_LOOP( node: j: key: val);
exsr load_subfield;
enddo;
enddo;
begsr load_subfield;
select;
when key = 'EquipmentHeader';
val = YAJL_object_find(node:'UnitInstallDateTime');
val = YAJL_object_find(list:'UnitInstallDateTime');
result.list(i).I_TJMAK = yajl_get_string(val);
endsl;
endsr;
Thx.
Scott
************Beginning of data**************
{"Fleet":{"Equipment":[{"EquipmentHeader":{"UnitInstallDateTime":"2019-04-26T15:
07:24.0000000+00:00","Make":"Skytrak","Model":"6042","EquipmentID":"181195","Ser
ialNumber":"0160095778"},"Location":{"Latitude":30.169664,"Longitude":-97.78923,
"DateTime":"2019-06-19T00:00:00.0000000+00:00"}},
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Frpg400-l&data=02%7C01%7C%7C9fa5f28b7c5946c4435d08d6f98446a7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636970743852110923&sdata=Xp6oXWbvh%2BlHjwapnTt6pCGuVNgPssol5zC1iUaagYM%3D&reserved=0
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Frpg400-l&data=02%7C01%7C%7C9fa5f28b7c5946c4435d08d6f98446a7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636970743852110923&sdata=B%2BQlwmsj3Az9xNlgzWDY3D5zlEWgw0EnMuZ%2Fj7ae4ds%3D&reserved=0.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com&data=02%7C01%7C%7C9fa5f28b7c5946c4435d08d6f98446a7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636970743852110923&sdata=znXrgvUnTzA1aWQNhmT4q8BkAp9zj9fRWMVm0OAw82E%3D&reserved=0
As an Amazon Associate we earn from qualifying purchases.