Struggling with iterating through the following return json string from an API:
{
"data": [
{
"ActionNeeded": null,
"OldestStatus": null,
"ServiceHost": "W501",
"ServiceName": "Renewals",
"ServiceStatusDateTime": "2023-03-15T22:47:05.313000",
"ServiceVersion": "1.0.0",
"SortOrder": "0",
"TimeAgo": null
},
{
"ActionNeeded": null,
"OldestStatus": null,
"ServiceHost": "W202",
"ServiceName": "Monitor",
"ServiceStatusDateTime": "2023-03-15T22:46:42.560000",
"ServiceVersion": null,
"SortOrder": "1",
"TimeAgo": null
},
{
"ActionNeeded": null,
"OldestStatus": null,
"ServiceHost": "W0070204",
"ServiceName": "Monitor",
"ServiceStatusDateTime": "2023-03-15T22:46:39.840000",
"ServiceVersion": "2.0.2",
"SortOrder": "1",
"TimeAgo": null
}
]
]
I've tried a for..in loop, but am only managing to get the first "set" of key/value pairs.
Here is my current code:
var json_obj = JSON.parse(event.data);
// Returned records
const items = json_obj['data'];
for (var item_index in items) {
if (items.hasOwnProperty(item_index)) {
console.log(item_index);
}
}
How can I loop through each "set" of data and out both key and value?