I have the following JSON output from an external site:
{
"foo":"bar",
"poo":1,
"boo":67,
"articles":{
"1329800400":[
{
"id":"234",
"title":"Title of This Article",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"287.3200",
},
{
"id":"212",
"title":"Another Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"199.0530",
},
{
"id":"196",
"title":"A Third Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"217.0250",
}
],
"1329714000":[
{
"id":"176",
"title":"Yet Another Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"219.6890",
},
{
"id":"155",
"title":"The Last Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"228.2570",
}
]
}
}
I want to GET the file via PHP and reformat the structure to be like:
{
"1": {
"id":"234",
"title":"Title of This Article",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"287.3200",
"pubDate":"1329800400"
},
"2": {
"id":"212",
"title":"Another Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"199.0530",
"pubDate":"1329800400"
},
"3": {
"id":"196",
"title":"A Third Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"217.0250",
"pubDate":"1329800400"
},
"4": {
"id":"176",
"title":"Yet Another Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"219.6890",
"pubDate":"1329714000"
},
"5": {
"id":"155",
"title":"The Last Article Title",
"url":"http:\/\/www.test.com\/path-to-article.html",
"thumb":"http:\/\/www.test.com\/path-to-image.jpg",
"attachment":"http:\/\/www.test.com\/path-to-attachment.mp3",
"duration":"228.2570",
"pubDate":"1329714000"
}
}
How hard would this be? Notice how the pubDate goes from being a parent to a child. Also keep in mind that I will never know the values of the pubDates -- they change on a daily basis. Thanks in advance for any suggestions!