If I understood your task correctly, then you need to make items not an object but an array, which, later, will hold objects with id and count properties.
Therefore, we rewrite var items = {}; on
var items = [];
Now we have the standard methods and functions of the array in js and we can use push add an object with the properties we need to the array
items.push({id: id, count: count});
Your code is off the shelf.
var items = []; $('.shop-one').each(function () { var clicks = $(this).find('.add_shop_content'); if(clicks.data('clicks')) { var count = $(this).find('input').val(); var id = $(this).children('input').val(); items.push({id: id, count: count}); }; });
idproperty theidvalue, and thecountcount property the value. - user190134items- This is an object, the keys in the object are unique. Therefore, it is impossible to make several identical keys in any way - Grundy