I have an array of Objects that looks like this:
$scope.images = [
{key: 'shop1/images/a1.jpg'},
{key: 'shop2/images/a2.jpg'},
{key: 'shop1/images/a3.jpg'},
{key: 'shop3/images/a4.jpg'}
]
My goal is to transform the above JSON into the following array of objects:
[
{ 'key':'shop1', 'images':['shop1/images/a1.jpg', 'shop1/images/a3.jpg'] }
{ 'key':'shop2', 'images':['shop2/images/a2.jpg'] }
{ 'key':'shop3', 'images':['shop3/images/a4.jpg'] }
]
Check out the fiddle here: http://jsfiddle.net/ojehojf8/