3

Iterating through JSONModel with multiple nested a...

 4 weeks ago
source link: https://community.sap.com/t5/technology-q-a/iterating-through-jsonmodel-with-multiple-nested-arrays/qaq-p/13676611
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Iterating through JSONModel with multiple nested arrays

ronhagan

Product and Topic Expert

yesterday

I have  UI5 application that executes a GET request and returns the data to the UI as a JSONModel.  I'm trying to iterate through the results to get to the data I want but am having challenges.

Below is a sample of the data with just 2 results.  I'm trying to get to the oData section and I'm obviously not doing it right.

Interesting that in the Dev Tools of Chrome, it appears a little differently, showing the indexes of the array rows in oData.  I put a screen shot below the JSONModel data.

Any ideas and/or suggestions anyone has would be greatly appreciated.

Thanks in advance!

***********************************************************************

JSONModel data:

{
"pSequentialImportCompleted": {},
"mEventRegistry": {},
"mMessages": {},
"id": "id-1713560453764-17",
"aBindings": [],
"oBindingsToRemove": {},
"mContexts": {},
"oData": [
{
"pipelinerunseq": 20547673299878010,
"starttime": "2024-03-05T13:05:38.693Z",
"stoptime": "2024-03-05T13:06:49.992Z",
"stagetype": "CompensateAndPay",
"status": "Successful",
"command": "PipelineRun",
"period": "June 2022",
"numerrors": 0,
"numwarnings": 2,
"time": "13:05",
"daydate": "05"
},
{
"pipelinerunseq": 20547673299878010,
"starttime": "2024-03-05T13:07:21.975Z",
"stoptime": "2024-03-05T13:08:04.098Z",
"stagetype": "CompensateAndPay",
"status": "Successful",
"command": "PipelineRun",
"period": "June 2022",
"numerrors": 0,
"numwarnings": 2,
"time": "13:07",
"daydate": "05"
}
],
"sDefaultBindingMode": "TwoWay",
"bDestroyed": false,
"bLegacySyntax": false,
"sRemoveTimer": null,
"iSizeLimit": 100,
"mSupportedBindingModes": {
"OneWay": true,
"TwoWay": true,
"OneTime": true
},
"mUnsupportedFilterOperators": {
"Any": true,
"All": true
},
"sUpdateTimer": null,
"bCache": true,
"aPendingRequestHandles": []
}

What shows in Dev Tools:

ronhagan_0-1713567046853.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK