Есть JSON файл:
{
"1" : {
"name" : "ЗАМКИ ВРЕЗНЫЕ",
"image" : "../images/products/padlocks/padlock_1.jpg",
"href" : "../products/vreznie.php",
"items" : {
"1" : {
"name" : "ЗАМОК 15-01",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
},
"2" : {
"name" : "ЗАМКИ 15-02",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
}
}
},
"2" : {
"name" : "ЗАМКИ НАВЕСНЫЕ",
"image" : "../images/products/padlocks/padlock_2.jpg",
"href" : "../products/padlock.php",
"items" : {
"1" : {
"name" : "ЗАМОК 16-01",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
},
"2" : {
"name" : "ЗАМКИ 16-02",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
},
}
},
"3" : {
"name" : "ЗАМКИ НАКЛАДНЫЕ",
"image" : "../images/products/padlocks/padlock_3.jpg",
"href" : "../products/nakladnie.php",
"items" : {
"1" : {
"name" : "ЗАМОК 17-01",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
},
"2" : {
"name" : "ЗАМКИ 17-02",
"image" : "../images/products/padlocks/padlock_1.jpg",
"color" : "black",
"size" : "30м",
"cost" : "3$"
},
}
}
}
Есть парсер этого файла:
$.getJSON("../databases/goods/padlock.json", function (data) {
var goods = data;
var out = '';
for (var key in cart) {
out += '<div class="single_goods" style="padding-right: 0px; padding-left: 0px;">';
out += '<b>' + goods[key].name + '</b>';
out += '<button type="button" class="btn btn-danger delete" data-art="' + key + '" style="border-radius: 0;">X</button>';
out += '<img src="' + goods[key].image + '">';
out += '<p> Размер: ' + goods[key].size + '</p>';
out += '<p> Цвет: ' + goods[key].color + '</p>';
out += '<p> Кол-во: <span class="btn-group" role="group" aria-label="...">' + '<button data-art="' + key + '" class="minus many btn btn-default"> - </button>' + '<button class="many btn btn-default">'+ cart[key] + '</button>'+'<button class="plus many btn btn-default" data-art="' + key + '"> + </button>' + '</span> </p>'
out += '<div class="btn-group" style="width: 100%;">';
out += '<button type="button" class="btn btn-warning cost add" style="width: 100%; font-size: 1.7rem;""> Цена: ' + cart[key] * goods[key].cost + '$</button>';
out += '</div>';
out += '</div>';
}
$('#my-cart').html(out);
});
Вопрос: как мне указать парсеру на массив items? Тоесть парсить items у кажого объекта?