Using to jQuery to access JSON nested array starting with dates
I'm attempting to build a ajax call from some json data
-
jQuery.ajax({
type: "GET",
url: "websiteurl.com",
success: function(data)
{
jQuery.each(data, function(i, val) {
$("#label").append(document.createTextNode(val.label));
$("#url").append(document.createTextNode(val.url));
});
}
});
Here is the jSon (url I've been given)
-
{
"2019-01-29T00:00:00+00:00": [
{
"type": "refuse",
"label": "Refuse",
}
],
"2019-02-05T00:00:00+00:00": [
{
"type": "gardenwaste",
"label": "Garden Waste",
},
{
"type": "recycling",
"subtype": "redbox",
"label": "Red Box",
},
{
"type": "recycling",
"subtype": "bluebag",
"label": "Blue Bag",
},
{
"type": "recycling",
"subtype": "yellowbag",
"label": "Yellow Bag",
}
],
"2019-02-12T00:00:00+00:00": [
{
"type": "refuse",
"label": "Refuse",
}
],
"calendar": {
"label": "Collection Calendar"
}
}
I'm struggling to get it outputting, because the date will change and I want to show that - but then have the other data following, e.g.
Date: 2019-01-29T00:00:00+00:00 (Formatted which I can do)
Label: Refuse