nastya97core,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div id="mygroup">
<input type="text" name="sara">
<input type="text" name="bella">
</div>
<pre id="out"></pre>
<script>
let obj = {};
let items = document.querySelectorAll("input");
items.forEach(function(item) {
item.addEventListener('input', function() {
let myname = this.name;
let myvalue = this.value;
let id = this.parentNode.id;
obj[id] = obj[id] || {};
obj[id][myname] = myvalue;
out.innerHTML = JSON.stringify(obj);
});
});
</script>
</body>
</html>